Wordpress

How to Add Warning Notices for your Clients in WordPress

As a consultant, developer, or designer, sometimes you just get hired to do the project and leave. Often in these circumstances, many developers customize the WordPress admin area and remove all the main settings options, so the client cannot break the site. However, it is really frustrating when another developer comes in just to find out that he has to take out bunch of code to see the settings. Or even if the owner decides they want to do things themselves, they don’t have the freedom to do so. The whole point of WordPress is to empower the publisher and give them freedom to publish content the way they want. Therefore in this article, we will show you how to give your clients full administrative access, but include warning notices for them, so they know the consequences of their actions. By simply hooking into WordPress admin_notices hook, we can display a notice that may say “Warning – changing settings on this page may cause problem with your website’s design”.

Warning Notices for your Clients in WordPress

First open your theme’s functions.php file, and then paste the following:

1 add_action( 'admin_notices', 'my_admin_notice' );
2 function my_admin_notice(){
3      global $current_screen;</div>
4      if ( $current_screen->parent_base == 'options-general' )
5           echo '<div><p>Warning - changing settings on these pages may cause problems with your website’s design!</p></div>';
6 }

You can modify the notices for each screen.

Thanks to Jacob Goldman for pointing this trick out. This will be great for our clients.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s