I’m trying to add additional profile pages and then allow users to submit custom profile data through the pages. I want this data to be unique to each user and only viewable by that user. The code is below. I have little experience trying to build a plugin like this. When I reload the page, a new data table is created with a blank value. What am I doing wrong?

    // Add the admin page
    function wpse66004_add_users_page()
    $user_id = $GLOBALS['wpuserid'];
    $user_info = get_userdata($user_id);
    $username = $user_info->user_login;
    $this_username = $username . 'page1';
            // $page_title
             'Your data'
            // $menu_title
            ,'Private Page'
             // $capability
            // $menu_slug
    add_action( 'admin_menu', 'wpse66004_add_users_page' );
    // Render the users private admin page
    function my_show_extra_profile_fields( $user_id ) { 
    $user_id = $GLOBALS['wpuserid'];
    $user_info = get_userdata($user_id);
    $username = $user_info->user_login;
    $this_username = $username . 'page1';
    $student_address_up = add_user_meta( $user_id, 'up_address', $_POST['student_address'] );
    $student_address_down = get_user_meta( $user_id, 'up_address', true );
    <form action="/wp-admin/profile.php?page=<?php echo $this_username ?>" method="post">
    <h3>Extra profile information</h3>
        <table class="form-table">
                <th><label for="address">Address</label></th>
                    <input type="text" name="address" id="address" value="<?php echo esc_attr( $student_address_up );  ?>" class="regular-text" /><br />
                    <span class="description">Please enter your address.</span>
                <input type="submit" name="formSubmit" value="Submit" class="button-primary"/>
    if($_POST['formSubmit'] === "Submit")    
            $student_address_up = update_user_meta( $user_id, 'up_address', $_POST['student_address'] );

Read more here: update_user_meta not working


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: