I am using WordPress to create a recruitment site with subscription. This is what I did. Added a meta value for user role 'rec' which is a date of ending of subscription.

All worked fine.

But when recruiter searches from the form it ads ?as=something as the query string.

I want my url structure to be like this


uid is the User ID of a recruiter, it is being used to get the meta of date from user's data to find out if user can see this page or not. ?as=something is search string.

Right now whatever I add in the action of form when a user searches the url becomes


What I did was I added the code like this in search form.

<form method="get" id="sul-searchform" action="<?php the_permalink() ?>&uid=<?php echo $my_uid;?>" class="wg_search">

Any help would be appreciated.

  • LOL Sometimes I act dumb. '<?php $my_uid = get_current_user_id(); ?> ' Solved it through current user ID. There was no need of adding an extra query string. May 4, 2014 at 16:38
  • 1
    You should post your comment as an answer, then come back in two days and accept your own answer May 4, 2014 at 16:48
  • I am new to the platform it said I need to wait for one day before I can answer my own question. May 5, 2014 at 20:41

1 Answer 1


You should use 'add_query_arg' function, to do this.

It adds a single key & value or an associative array. You can set a key value to false to remove it from the query. Omitting the old query or the uri (second or third parameter) uses the $_SERVER value.

So in your case doing it like this should work:

... action="<?php echo add_query_arg( 'uid', get_current_user_id(), get_permalink() ); ?>" ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.