0

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 Aug 7 '17 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. – Rororr Nyako Aug 7 '17 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 Aug 7 '17 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. – Rororr Nyako Aug 7 '17 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 Aug 7 '17 at 14:58
0

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, privacy policy and cookie policy

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