In this tip we will add Gender and Location fileds in the ajax registration form :
Please refer the code and add it to the wplms-customizer.php file at the end and before “?>” in wplms customizer plugin :
add_filter('vibe_projects_registration_fields','wplms_modern_custom_registration_field');
function wplms_modern_custom_registration_field($fields){
$fields[] = array(
'label'=> __('Gender','wplms_modern'),
'placeholder'=> __('Enter Name','wplms_modern'),
'id'=> 'Gender',
'field' => 'select',
'options'=>Array('Male'=>__('Male','wplms-modern'),'Female'=>__('Female','wplms-modern')),
'validation'=>'',
'set' => 'core',
'class'=> 'form-control no-border',
'extras'=> array('data-parsley-trigger'=>'change'),
'required' => 1,
);
$fields[] = array(
'label'=> __('Location','wplms_modern'),
'placeholder'=> __('Enter Name','wplms_modern'),
'id'=> 'Location',
'field' => 'text',
'validation'=>'',
'set' => 'core',
'class'=> 'form-control no-border',
'extras'=> array('data-parsley-trigger'=>'change'),
'required' => 1,
);
return $fields;
}
add_action('vibe_projects_user_registered','wplms_modern_process_custom_fields',10,2);
function wplms_modern_process_custom_fields($fields,$user_id){
if(!empty($fields['Gender'])){
if(function_exists('xprofile_set_field_data')){
xprofile_set_field_data('Gender', $user_id, $fields['Gender']);
}
}
if(!empty($fields['Location'])){
if(function_exists('xprofile_set_field_data')){
xprofile_set_field_data('Location', $user_id, $fields['Location']);
}
}
}
Please note the strings “Gender” and “Location” from buddypress xprofile and provide the type also in the above code according to your field type .
like in above code for location ‘field’ => ‘text‘ and ‘id’=> ‘Location‘,
Note that the Gender is a select box type for this you need to add a “option” element in array like this in the above code :
'options'=>Array('Male'=>__('Male','wplms-modern'),'Female'=>__('Female','wplms-modern')),
