Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to: get_user_meta – BuddyPress

  • Avatar of kizzywizzy
    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)
  • Avatar of Renato Alves
    Renato Alves
    Participant

    @espellcaste

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

    Avatar of artifex223
    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)

You must be logged in to reply to this topic.