0

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

/recruitment/?uid=4&as=it

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

/recruitment/?as=it

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. – Ahmad Awais May 4 '14 at 16:38
  • 1
    You should post your comment as an answer, then come back in two days and accept your own answer – Pieter Goosen May 4 '14 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. – Ahmad Awais May 5 '14 at 20:41
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, privacy policy and cookie policy

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