add_action('um_after_account_general', 'showExtraFields', 100);
function showExtraFields(){
$custom_fields = [
"phone" => "Phone",
"Age" => "Age"
];
$fields = [];
foreach ($custom_fields as $key => $value) {
$fields[$key] = array(
'title' => $value,
'metakey' => $key,
'type' => 'text',
'label' => $value,
'required' => 1,
'public' => 1,
'editable' => 1,
'validate' => $key
);
}
$id = um_user('ID');
$fields = apply_filters( 'um_account_secure_fields', $fields, $id );
UM()->builtin()->saved_fields = $fields;
UM()->builtin()->set_custom_fields();
foreach( $fields as $key => $data )
$output .= UM()->fields()->edit_field( $key, $data );
echo $output;
}
add_action( 'um_submit_account_errors_hook', 'my_submit_account_errors', 10, 1 );
function my_submit_account_errors( $submitted ) {
global $ultimatemember;
if (strlen($submitted['phone'] ) > 9)
$ultimatemember->classes['form']->add_error('phone','Phone is too long');
}
function showExtraFields(){
$custom_fields = [
"phone" => "Phone",
"Age" => "Age"
];
$fields = [];
foreach ($custom_fields as $key => $value) {
$fields[$key] = array(
'title' => $value,
'metakey' => $key,
'type' => 'text',
'label' => $value,
'required' => 1,
'public' => 1,
'editable' => 1,
'validate' => $key
);
}
$id = um_user('ID');
$fields = apply_filters( 'um_account_secure_fields', $fields, $id );
UM()->builtin()->saved_fields = $fields;
UM()->builtin()->set_custom_fields();
foreach( $fields as $key => $data )
$output .= UM()->fields()->edit_field( $key, $data );
echo $output;
}
add_action( 'um_submit_account_errors_hook', 'my_submit_account_errors', 10, 1 );
function my_submit_account_errors( $submitted ) {
global $ultimatemember;
if (strlen($submitted['phone'] ) > 9)
$ultimatemember->classes['form']->add_error('phone','Phone is too long');
}
No comments:
Post a Comment