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

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?

2 Answers 2

update_user_meta($current_user->ID, 'description', $_POST['user_description']);

in the form processing function will save the bio.

I would keep the form action on the same admin page. As for data validation, I don't see what there is to validate in the first place. It's just a string - not an email, address or the like that needs to be checked against a certain format.


As in Johannes answer update_user_meta is pretty much all you need as far as data validation. Justin Tadlock has a great blog post on adding custom user meta fields. Just add the function that outputs the form on your new admin page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.