Adding a Confirmation Message Before Publishing a Post in WordPress

Have you ever accidentally Published your WordPress Post by mistake when you meant to save an incomplete article as a Draft for future work?

To be honest, until writing articles for this very blog, I didn’t realize just how often that could happen and I’m not a big fan of pop-up dialogues in general, but there are good some good use-cases for them and I now believe this is one.

Accidentally Publishing a Post can:

  • Trigger WordPress to add the article to your site’s RSS causing people to come see it early
  • It can get craweled by a search engine bot so that an incomplete article is indexed prematurely
  • It can auto-submit it to various Social Media company’s and it could have triggered an email newsletter to be sent in some cases.

That being said, this is WordPress and there are Plugins for this. Plugins can be installed to handle it easily and there’s also a way to handle without installing a plugin that is slightly more complicated by adding a tiny bit of code to your theme’s custom functions.php file. All of these methods will produce a confirmation dialogue when you Press the Publish button to confirm that you didn’t select it on accident. If you really want to Publish your article, simply select “Ok”, otherwise, cancel and you safely avoided mistakenly prematurely publishing your article.

First, let’s take a look at two Plugins that both nicely handle publish confirmation messages.

Publish Confirm

Publish Confirm

Pros:

  • Nothing to configure. Simply install and activate.
  • Ability to limit plugin functionality to a specific post type.
  • Change default dialogue message into something else with a function.

Cons:

  • Unable to limit to specific user roles.

Publish Confirm was created by pluginkollektiv, who has 11 Plugins in the WordPress Plugin Repository.

Confirm Publishing Actions

Confirm Publishing Actions

Pro’s:

  • Nothing to configure. Simply install and activate.
  • Ability to limit plugin functionality to a specific post type.
  • Ability to limit plugin functionality to selected user roles.

Con’s:

  • Hasn’t been updated in a year (as of this writing)

Confirm Publishing Actions was co-created by Peter J. Herrel who has 1 other Plugin in the WordPress Plugin Repository and inBytes.

Do It Without a Plugin

If you don’t want to add an other Plugin to your site, this can also be handled by adding a tiny bit of code to your theme’s functions.php file. As always, but sure you’re using a Child Theme so that your code isn’t over-written when the theme gets updated.


// This is the confirmation message that will appear.
$c_message = 'Are you SURE you want to publish this post?';

function confirm_publish(){

global $c_message;
echo '';
}
add_action('admin_footer', 'confirm_publish');
,
Previous Post
Customize Your WordPress Admin Area
Next Post
Protection Against DDoS attacks on Your WordPress Website

Related Posts

You must be logged in to post a comment.
Menu