Title: Get field value
Last modified: August 25, 2021

---

# Get field value

 *  [avatarcy](https://wordpress.org/support/users/avatarcy/)
 * (@avatarcy)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/get-field-value-2/)
 * Hi,
 * In user profile page, except of showing the fields data, I want to get the name
   and mobile number of current user to do something else. I am using PHP snippets
   and I wrote the following code to get the user name.
 * <?php
    $display_name = um_user(‘display_name’); echo $display_name; // prints
   the user’s display name ?>
 * BUT I cannot get the mobile number (field meta key is mobile_number) by using
   the following:
 * <?php
    $display_mobile = um_user(‘mobile_number’); echo $display_mobile; ?>
 * What am I doing wrong? Any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Contributor [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/get-field-value-2/#post-14817759)
 * Hi [@avatarcy](https://wordpress.org/support/users/avatarcy/)
 * Whose user’s data are trying to retrieve? Is it the currently logged-in user 
   or a specific user? If you need to retrieve the data of a specific user, you 
   will need the function `um_fetch_user`.
 * Here’s an example:
 *     ```
       $user_id = 123;
       um_fetch_user( $user_id ); // if this function is not added, it will retrieve the currently logged-in user's data.
       $display_mobile = um_user( "mobile_number" );
       ```
   
 * Regards,
 *  Plugin Contributor [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/get-field-value-2/#post-14853668)
 * Hi [@avatarcy](https://wordpress.org/support/users/avatarcy/)
 * …Please feel free to re-open this thread by changing the Topic Status to ‘Not
   Resolved’ if any other questions come up and we’d be happy to help. 🙂
 * Regards,
 *  Thread Starter [avatarcy](https://wordpress.org/support/users/avatarcy/)
 * (@avatarcy)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/get-field-value-2/#post-14855604)
 * It works if the user is locked in. What about when you are not logged in and 
   you are just viewing the profile page of a user. I want in this situation to 
   get the name and mobile number of this user. Can I do this or you have to login
   in to get them?
 *  Plugin Contributor [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/get-field-value-2/#post-14858410)
 * Hi [@avatarcy](https://wordpress.org/support/users/avatarcy/)
 * IF you are viewing a profile while currently logged-out, you can try this code
   snippet:
 *     ```
       $user_id = um_profile_id();
       um_fetch_user( $user_id ); // if this function is not added, it will retrieve the currently logged-in user's data.
       $display_mobile = um_user( "mobile_number" );
       ```
   
 * Regards,
 *  Thread Starter [avatarcy](https://wordpress.org/support/users/avatarcy/)
 * (@avatarcy)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/get-field-value-2/#post-14861713)
 * Great, working just fine. Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Get field value’ is closed to new replies.

 * ![](https://ps.w.org/ultimate-member/assets/icon-256x256.png?rev=3160947)
 * [Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin](https://wordpress.org/plugins/ultimate-member/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ultimate-member/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ultimate-member/)
 * [Active Topics](https://wordpress.org/support/plugin/ultimate-member/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ultimate-member/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ultimate-member/reviews/)

## Tags

 * [retrieve](https://wordpress.org/support/topic-tag/retrieve/)

 * 5 replies
 * 2 participants
 * Last reply from: [avatarcy](https://wordpress.org/support/users/avatarcy/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/get-field-value-2/#post-14861713)
 * Status: not resolved