Want a Custom Profile Avatar

Support MB User Meta Want a Custom Profile AvatarResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17699
    NicNic
    Participant

    Hello,

    I am attempting to give users an upload field for a profile photo that I can display on my site. However, I have been struggling with how to get the profile photo to display on the front end. I have tried the code on https://docs.metabox.io/extensions/mb-user-meta/ at the bottom, but it doesn't display any data when there is data present for my custom field.

    Any ideas?Here is the data for my custom image field that is set to show for "users" in the settings tab.

    Field type: Image
    Field Name: profile_photo
    Fieldset Name: support-agent-profile

    #17716
    Anh TranAnh Tran
    Keymaster

    Hi Nicole,

    You need to get the user ID first, and then use the helper function to get the image. This is a sample code you can start with:

    $user_id = get_current_user_id();
    $images = rwmb_meta( 'support-agent-profile', ['object_type' => 'user'], $user_id );
    $image = $images[0];
    echo "<img src='{$image['url'}'>";

    You might want to change the code to get user ID if that's not the current user.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.