Support Forum
Support › MB User Profile › MB User Profile -> Registration form -> inherit field valuesResolved
Hi,
I have a user registration form which asks for first_name and last_name which corresponds to the WP first/lastname.
In addition, user has to enter one or more children and their names. I would like the last name of each children to "inherit" the entered last_name.
Is that possible at all?
Thanks
Martin
add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
function your_prefix_register_meta_boxes( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = array (
'id' => 'dsk-user-registration',
'fields' => array(
array (
'id' => $prefix . 'first_name',
'type' => 'text',
'name' => esc_html__( 'First Name', 'text-domain' ),
),
array (
'id' => $prefix . 'last_name',
'type' => 'text',
'name' => esc_html__( 'Last Name', 'text-domain' ),
),
array (
'id' => $prefix . 'dsk_user_registration_mobile_number',
'type' => 'text',
'name' => esc_html__( 'Mobile Number', 'text-domain' ),
'required' => 1,
),
array (
'id' => $prefix . 'dsk_user_registration_group_child',
'type' => 'group',
'name' => esc_html__( 'Child(ren)', 'text-domain' ),
'fields' => array(
array (
'id' => $prefix . 'dsk_user_registration_group_child_firstname',
'type' => 'text',
'name' => esc_html__( 'First Name', 'text-domain' ),
'required' => 1,
),
array (
'id' => $prefix . 'dsk_user_registration_group_child_lastname',
'type' => 'text',
'name' => esc_html__( 'Last Name', 'text-domain' ),
'required' => 1,
),
array (
'id' => $prefix . 'dsk_user_registration_group_child_legal_guardian_type',
'name' => esc_html__( 'Your relationship', 'text-domain' ),
'type' => 'radio',
'options' => array(
'Father' => esc_html__( 'Father', 'text-domain' ),
'Mother' => esc_html__( 'Mother', 'text-domain' ),
'Other' => esc_html__( 'Other', 'text-domain' ),
),
'inline' => 1,
'required' => 1,
),
),
'clone' => 1,
'default_state' => 'expanded',
'add_button' => esc_html__( 'Add additional child', 'text-domain' ),
),
),
'type' => 'user',
);
return $meta_boxes;
}
Hi Martin,
I think you should do some custom JS code to update the value of the children's first name based on value of their parent's first name. Unfortunately, we don't have that feature built-in.