Hi,
If you have the field number
for the user and it has the ID fav_number
, then you can use this code to get the user meta and set it as the default value when registering the field number
for the post.
add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
function your_prefix_function_name( $meta_boxes ) {
$current_user_id = get_current_user_id();
$default_number = get_user_meta( $current_user_id, 'fav_number', true );
$meta_boxes[] = [
'title' => __( 'Post Meta', 'your-text-domain' ),
'id' => 'post-meta',
'fields' => [
[
'name' => __( 'Number', 'your-text-domain' ),
'id' => 'number',
'type' => 'number',
'std' => $default_number
],
],
];
return $meta_boxes;
}
Refer to the documentation
https://developer.wordpress.org/reference/functions/get_user_meta/
https://docs.metabox.io/field-settings/#default-value