Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to: get_user_meta – BuddyPress


  • kizzywizzy
    Participant

    @kizzywizzy

    What is the proper way to display User Meta in the BP Loop using this line from codex?

    ` get_user_meta($user_id, $key, $single);`

    I added that line to the profile loop and switched those values with ones from my DB and nothing happened. What am I doing wrong?

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

  • Renato Alves
    Moderator

    @espellcaste

    Could you provide the code you used so that I can see what was wrong?


    artifex223
    Participant

    @artifex223

    @kizzywizzy – The function get_user_meta() just returns the data; it does not display it. So if that is the only line of code you’ve added, you won’t see any output. You’ll want to assign the output of the function to a variable and echo that, or just echo the output directly.

    Here is the example from the Codex:

    <?php 
      $user_id = 9;
      $key = 'last_name';
      $single = true;
      $user_last = get_user_meta( $user_id, $key, $single ); 
      echo '<p>The '. $key . ' value for user id ' . $user_id . ' is: ' . $user_last . '</p>'; 
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to: get_user_meta – BuddyPress’ is closed to new replies.
Skip to toolbar