I just want to know how can I make variables on my wordpress link? so can I make get function on my page.

Example I have url page www.example.com?page=123 and add some variable like mobile number.

So it should be like this www.example.com?page=123&mobile_number=12342

*The mobile_number save inside usermeta of a logged user. This is possible on wordpress?

  • I would note that this would expose the users mobile number to any traffic logging or visitor stats systems, browser history, etc, posing a data protection problem. Consider the data laws of the countries you're operating in else you might face hefty fines
    – Tom J Nowell
    Commented Aug 7, 2017 at 14:35
  • But what are the other ways to get number/details of my logged user? Cause all of their details save to usermeta table. Commented Aug 7, 2017 at 14:38
  • then use a user ID or username instead, to simplify things you may wish to repurpose the author archives into user profiles
    – Tom J Nowell
    Commented Aug 7, 2017 at 14:39
  • my problem is how can I show their user id on page they are visiting? When I go to a page it only shows my page id my user id are not showing. Commented Aug 7, 2017 at 14:48
  • you need to put it in there in the links the user clicks, see interactives answer below for how to fetch user meta. Once the page is loaded you can't add the data in hindsight, it's too late
    – Tom J Nowell
    Commented Aug 7, 2017 at 14:58

1 Answer 1


Assuming the user's mobile number is saved in wp_usermeta with meta_key being mobile_number, then adding this to a template will show the current user's mobile number:

<?php echo get_user_meta( get_current_user_id(), 'mobile_number', true ); ?>

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.