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 );