I have removed the edit profile page from WP admin as I don't want users to be able to edit their details as this is a closed intranet and their details are fed from AD.

However I do want them to be able to publish their own user description (Biography). So I've set out to add a new admin page to give the user the ability to do that:

add_action('admin_menu', 'sc_stace_user_bio_page');
function sc_stace_user_bio_page() {
    $page = add_menu_page( "Your Biography", "Biography", "read", "user-bio", "sc_stace_user_bio_page_content", "", 50 );
}

function sc_stace_user_bio_page_content() {
    global $current_user;
    get_currentuserinfo();
    ?>
    <div class="wrap">
        <h2>Your Biography</h2>
        <form action="options.php" method="post">
            <textarea rows="10" cols="100" name="user_description"><?php echo esc_textarea($current_user->user_description); ?></textarea>
            <?php submit_button( "Save", "primary", "submit", true ); ?>
        </form>
    </div>
    <?php
}
?>

As far as I know I cannot use the Settings API here as this info needs saving into the logged in users meta not into options table. So now I'm stuck as I don't know where the form should be saving to and how to check for form submission the correct way.

So where should I be submitted the form to? What nonces if any should I be putting in the form? What do I need to hook into for checking form submission and if correct data is being sent save to user's meta?

没有正确的解决方案

许可以下: CC-BY-SA归因
scroll top