• Resolved michaelpersch

    (@michaelpersch)


    Hello,

    I want to display a custom field of a user on the profile page at a certain place.
    How can I access it via PHP?

    I tried this:

    //get the user name from the parameter in the URL
    $profile_user_name = htmlspecialchars($_GET['um_user']);
    
    //Get the corresponding user
    $profile_user = get_user_by('login', $profile_user_name);
    
    //Get the user ID from the user, already seems not to work
    $profile_user_id = $profile_user->ID;
    
    //And now the age
    $profile_user_age = get_user_meta( $profile_user_id, 'user_age', true );

    My way does not work and even if it would, isn’t there a shorter way?

    Thank you!

    Edit: Got it, the answer is um_profile_id()

    • This topic was modified 1 year, 11 months ago by michaelpersch.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to display a custom field of a specific user?’ is closed to new replies.