Custom Fields
Support MB User Profile User Profile and display_name

  • Creator
  • #17120
    Resolved pza

    I've added a field group with a text field, ID = display_name as indicated here:

    But when a profile is edited using MB user profile, it saves the field value only.

    The user display name is not updated. Is there another ID or process required to make display_name work? Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
  • #17655

    I never could figure this out. User "display name" can not be updated via user profile?

    Anh Tran

    Hi pza, sorry for the delay. At the moment, it's not possible yet, because display_name is not a custom user meta. It's a field in the users table. I'll update the plugin to support it and all user fields.


    By the way in case it helps anyone, here's what I ended up doing:

    • custom text field named display_name in user profile
    • for user profile, a field group with ID user-profile
    • the following code to update user info after saving the MB profile
    add_action( 'rwmb_profile_after_process', function( $config, $user_id ) {
        if ( $config['id'] == 'user-profile' ) {
            if ( $uname = $_POST['display_name'] ) {
                $args = array(
                    'ID' => $user_id,
                    'display_name' => $uname
                $update = wp_update_user($args);
    }, 10, 2 );
    • and this to update the default profile field value in case it was changed elsewhere (ie. Edit account page)
    add_filter( 'rwmb_display_name_field_meta', function( $meta, $field, $saved ) {
        $current_user = wp_get_current_user();
        return $current_user->display_name;
    }, 10, 3 );
    Anh Tran

    I've added support for display_name and other user fields in version 1.7.0. Thanks @pza for your suggestion.

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