I have a page (in Wordpress) which contains an embedded database report form. The form is configured to filter the results based upon the query string of the page URL. The query string is specific to the user so that each user sees results that are applicable to them.
I have written a PHP script in the page template which produces the correct URL, with query string added. What I would now like to do is reload the page using that url+query, BUT without getting stuck in an endless redirect loop!
The code below does what I want, EXCEPT that it (obviously) gets stuck in a loop! I have tried using exit
or die
commands, but that doesn't seem to help.
<?php
$user_info = get_userdata(1);
$url = esc_url(add_query_arg( array(
'tbl_invites_username' => $user_info->user_number,
'tbl_events_event_id' => '1'),
'http://www.example.com/' ));
header("location: " .$url);
?>
I am new to this, so I appreciate that there may be an entirely different way to achieve the same result - I am open to suggestions!
Basically, when the user clicks on a link to the page containing the form, I want them to see a form with results filtered for them.