I want to update my user meta table

Question

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 );
    }


?>
0
Jerin Jackson 4 years 2017-04-25T20:15:35-05:00 0 Answers 78 views 0

Leave an answer

Browse
Browse