Custom Fields
Re-Envisioned
Support MB User Meta Want a Custom Profile Avatar

  • Creator
    Topic
  • #17699
    Resolved Nicole
    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

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #17716
    Anh 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 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
grid gear info copy caret-up caret-down trash