admin管理员组文章数量:1122846
I have a form with the fields name, address, class, and age. When I enter a new registry, the name field gets updated in the table wp_users
.
Once the ID is saved, I am trying to update the user meta fields such as address, which is not happening. Below is my PHP code. Please Help me:
<?php
$userdata = array(
'user_login' => $_POST['usname'],
'user_pass' => $_POST['passw'] // When creating an user, `user_pass` is expected.
);
$user_id = wp_insert_user( $userdata ) ;
//On success
if ( ! is_wp_error( $user_id ) ) {
echo "User created : ". $user_id;
}
if(isset($_REQUEST['r_submit']))
{
$id = $_GET['ID'];
$user_id = $id;
$meta_key = "address";
$meta_value = $_REQUEST['address'];
update_user_meta( $user_id, $meta_key, $meta_value );
}
?>
I have a form with the fields name, address, class, and age. When I enter a new registry, the name field gets updated in the table wp_users
.
Once the ID is saved, I am trying to update the user meta fields such as address, which is not happening. Below is my PHP code. Please Help me:
<?php
$userdata = array(
'user_login' => $_POST['usname'],
'user_pass' => $_POST['passw'] // When creating an user, `user_pass` is expected.
);
$user_id = wp_insert_user( $userdata ) ;
//On success
if ( ! is_wp_error( $user_id ) ) {
echo "User created : ". $user_id;
}
if(isset($_REQUEST['r_submit']))
{
$id = $_GET['ID'];
$user_id = $id;
$meta_key = "address";
$meta_value = $_REQUEST['address'];
update_user_meta( $user_id, $meta_key, $meta_value );
}
?>
Share
Improve this question
edited Apr 26, 2017 at 1:26
Dave Romsey
17.9k11 gold badges55 silver badges70 bronze badges
asked Apr 26, 2017 at 1:15
Jerin JacksonJerin Jackson
112 bronze badges
1 Answer
Reset to default 0changing the code as below gave me my answer :
$userdata = array(
'user_login' => $_POST['usname'],
'user_pass' => $_POST['passw'] // When creating an user, `user_pass` is expected.
);
$user_id = wp_insert_user( $userdata ) ;
update_user_meta( $user_id, 'address', $_REQUEST['address'] );
update_user_meta( $user_id, 'age', $_REQUEST['age']);
update_user_meta( $user_id, 'class', $_REQUEST['class']);
//On success
if ( ! is_wp_error( $user_id ) ) {
echo "User created : ". $user_id;
}
本文标签: I want to update my user meta table
版权声明:本文标题:I want to update my user meta table 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736291073a1928647.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论