'phone-number', // 'label' => 'Phone number', // ), // array( // 'service' => 'address', // 'label' => 'Address', // ), // ); // foreach ( $new_methods as $method ) { // if( ! isset( $contact_methods[$method['service']] ) ) { // $contact_methods[$method['service']] = $method['label']; // } // } // return $contact_methods; // } function render_profile_fields( $user ) { ?>

More Information



10) { $errors->add( 'phone', "ERROR: The maximum phone length is 10 characters." ); } if ( preg_match( $phone_regex, $_POST['phone'] ) == 0 ) { $errors->add( 'phone', "ERROR: Not a valid phone number." ); } return $errors; } function save_profile_fields( $id ) { // save input fields values $phone_regex = "/08[789]\d{7}/u"; if ( !current_user_can( 'edit_user', $id ) ) return false; if ( isset( $_POST['phone'] )) { if ( preg_match( $phone_regex, $_POST['phone'] ) == 1 ) { update_user_meta( $id, 'phone', sanitize_text_field( $_POST['phone'] ) ); } } if ( isset( $_POST['address'] ) ) { update_user_meta( $id, 'address', sanitize_text_field( $_POST['address'] ) ); } } }