I have created a front-end posting and dashboard system for my users to add and edit their own posts. In the dashboard area, I have a list of their posts and the following options for each post: View | Edit | Publish/Un-Publish | Delete

I have all of these links working except for the "un-publish" part. I can get a post to publish if it's currently in draft, but once it publishes I can't figure out how to "unpublish" it from the front end, which is a function I'd like my users to have.

For reference, I am using code from this thread to do the Publish part: Front-End Post Submission

I've tried adapting it, but have not succeeded.

I also need similar functionality on the New Post form where I'd like to display a "Save Post" button along side the "Publish" button so a user can save the post a draft so as to not risk losing their work while creating the post.

Thanks for reading, and hopefully someone can help!

1 Answer 1


You can use wp_update_post() to change the status of a post.

global $current_user;

$post_id = $_GET['post_id'];
$the_post = get_post( $post_id );

if ( $the_post->post_author == $current_user->ID && $the_post ) {
    $the_post->post_status = 'draft';
    wp_update_post( $the_post );    

Use wp_insert_post() with post_status => 'draft' to save a post.

  • Thank you, this was helpful! I also don't completely understand nonce yet so there was also an error going on there. Thanks for your help.
    – Eckstein
    Nov 10, 2012 at 6:21

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.