From cf1261ebf098dc0e644544ca2e57ceadfe51c476 Mon Sep 17 00:00:00 2001 From: pgmatev Date: Mon, 13 Jul 2020 19:03:33 +0300 Subject: fixed saving after validation; changed file names to match proposed naming --- wp-content/plugins/dx-users/users-class.php | 99 +++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 wp-content/plugins/dx-users/users-class.php (limited to 'wp-content/plugins/dx-users/users-class.php') diff --git a/wp-content/plugins/dx-users/users-class.php b/wp-content/plugins/dx-users/users-class.php new file mode 100644 index 0000000..958d12b --- /dev/null +++ b/wp-content/plugins/dx-users/users-class.php @@ -0,0 +1,99 @@ + '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'] ) ); + } + } +} \ No newline at end of file -- cgit v1.3.1-26-gb76a