admin管理员组

文章数量:1336633

$creating = isset( $_POST['createuser'] );

$new_user_login             = $creating && isset( $_POST['user_login'] ) ? wp_unslash( $_POST['user_login'] ) : '';
$new_user_firstname         = $creating && isset( $_POST['first_name'] ) ? wp_unslash( $_POST['first_name'] ) : '';
$new_user_lastname          = $creating && isset( $_POST['last_name'] ) ? wp_unslash( $_POST['last_name'] ) : '';
$new_user_email             = $creating && isset( $_POST['email'] ) ? wp_unslash( $_POST['email'] ) : '';
$new_user_uri               = $creating && isset( $_POST['url'] ) ? wp_unslash( $_POST['url'] ) : '';
$new_user_phone             = $creating && isset( $_POST['phone'] ) ? wp_unslash( $_POST['phone'] ) : '';
$new_user_role              = $creating && isset( $_POST['role'] ) ? wp_unslash( $_POST['role'] ) : '';
$new_user_send_notification = $creating && ! isset( $_POST['send_user_notification'] ) ? false : true;
$new_user_ignore_pass       = $creating && isset( $_POST['noconfirmation'] ) ? wp_unslash( $_POST['noconfirmation'] ) : '';

?>

this is my code but when i add user and save it, it won't add more field in the database for phone

$creating = isset( $_POST['createuser'] );

$new_user_login             = $creating && isset( $_POST['user_login'] ) ? wp_unslash( $_POST['user_login'] ) : '';
$new_user_firstname         = $creating && isset( $_POST['first_name'] ) ? wp_unslash( $_POST['first_name'] ) : '';
$new_user_lastname          = $creating && isset( $_POST['last_name'] ) ? wp_unslash( $_POST['last_name'] ) : '';
$new_user_email             = $creating && isset( $_POST['email'] ) ? wp_unslash( $_POST['email'] ) : '';
$new_user_uri               = $creating && isset( $_POST['url'] ) ? wp_unslash( $_POST['url'] ) : '';
$new_user_phone             = $creating && isset( $_POST['phone'] ) ? wp_unslash( $_POST['phone'] ) : '';
$new_user_role              = $creating && isset( $_POST['role'] ) ? wp_unslash( $_POST['role'] ) : '';
$new_user_send_notification = $creating && ! isset( $_POST['send_user_notification'] ) ? false : true;
$new_user_ignore_pass       = $creating && isset( $_POST['noconfirmation'] ) ? wp_unslash( $_POST['noconfirmation'] ) : '';

?>

this is my code but when i add user and save it, it won't add more field in the database for phone

Share Improve this question asked Jun 9, 2020 at 7:35 Maxwell DavidMaxwell David 11 bronze badge 1
  • There's nothing in this code that saves anything. It's just setting variables. Is this all of it? – Jacob Peattie Commented Jun 9, 2020 at 7:57
Add a comment  | 

1 Answer 1

Reset to default 0

You want to use the Wordpress function; add_user_meta

add_user_meta( $user_id, '_level_of_awesomeness', $awesome_level);

https://developer.wordpress/reference/functions/add_user_meta/

本文标签: how add more field to wp user and save it to database