Custom Fields
Support MB User Meta Want a Custom Profile Avatar

  • Creator
  • #17699
    Resolved Nic


    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 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
  • #17716
    Anh Tran

    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.