I’m trying to post an array value but instead of posting the value (’’,‘I am a parent’,‘I am a teacher’,‘I am a student’), it appears to post the key instead (0,1,2,3).
The array is used for an dropdown menu.
Please an anyone help?
function add_tml_registration_form_fields() {
tml_add_form_field( 'register', 'customer_type', array(
'type' => 'dropdown',
'label' => 'Please select whether you are a student, teacher or parent.',
'value' => tml_get_request_value( 'customer_type', 'post' ),
'id' => 'customer_type',
'options' => array('','I am a parent','I am a teacher','I am a student'),
'priority' => 15,
) );
}
add_action( 'init', 'add_tml_registration_form_fields' );
function save_tml_registration_form_fields( $user_id ) {
if ( ! empty( $_POST['customer_type'] ) ) {
update_user_meta( $user_id, 'customer_type', $_POST['customer_type'] );
}
}
add_action( 'user_register', 'save_tml_registration_form_fields' );