function populate_posts($form){ foreach($form['fields'] as &$field){ if($field['defaultValue'] != '{referer}') continue; //Check referrer field, if exists and HTTP referrer not set, try to fill it manually if($field['defaultValue'] == '{referer}' && ! isset($_SERVER['HTTP_REFERER'])) { $field['defaultValue'] = _getReferrerUrl(); continue; } } return $form; } function _getReferrerUrl() { $url = 'Referrer niet beschikbaar'; if(isset($_GET['occ_id'])) $url = get_option('home') . '/occasion/' . $_GET['occ_id']; if(isset($_GET['post_id'])) $url = get_permalink($_GET['post_id']); return $url; } //Add these for each form, where the last number is the form id add_filter('gform_pre_render_1', 'populate_posts'); add_action("gform_admin_pre_render_1", "populate_posts");