From b4d0ab60a0da25c1ee95134d936b998e1e491975 Mon Sep 17 00:00:00 2001 From: pgmatev Date: Wed, 8 Jul 2020 14:52:14 +0300 Subject: new method for custom user fields; hook error --- wp-content/plugins/dx-users/class.cm.php | 88 ++++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 20 deletions(-) (limited to 'wp-content/plugins/dx-users/class.cm.php') diff --git a/wp-content/plugins/dx-users/class.cm.php b/wp-content/plugins/dx-users/class.cm.php index 4f1dc85..23d07e4 100644 --- a/wp-content/plugins/dx-users/class.cm.php +++ b/wp-content/plugins/dx-users/class.cm.php @@ -1,28 +1,76 @@ 'phone-number', - 'label' => 'Phone number', - ), - array( - 'service' => 'address', - 'label' => 'Address', - ), - ); + // function add_custom_box_user($contact_methods) { + // $new_methods = array( + // array( + // 'service' => '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']; - } - } + // foreach ( $new_methods as $method ) { + // if( ! isset( $contact_methods[$method['service']] ) ) { + // $contact_methods[$method['service']] = $method['label']; + // } + // } - return $contact_methods; - } + // return $contact_methods; + // } + function renderProfileFields( WP_User $user ) { ?> + +

More Information

+ + + + + + + + + + +
+
+
+
+
+ + 10 && !empty( $_POST['phone'] ) ) + $errors->add( 'phone', "ERROR: The maximum phone length is 10 characters." ); + if ( !empty( $_POST['address'] ) && strlen( $_POST['address'] ) > 255 && !empty( $_POST['address'] ) ) + $errors->add( 'address', "ERROR: The maximum address length is 255 characters." ); //Unsure what address validation to use -} + return $errors; + } + + function saveProfileFields( $id ) { + // save input fields values + if ( !current_user_can( 'edit_user', $id ) ) + return false; + + if ( isset( $_POST['phone'] ) ) + update_user_meta( $id, 'phone', $_POST['phone'] ); + + if ( isset( $_POST['address'] ) ) + update_user_meta( $id, 'address', $_POST['address'] ); + } +} \ No newline at end of file -- cgit v1.3.1-26-gb76a