iBlognet

Custom Dashboard Widget For Specific User Roles

by Sahil Umatia

wordpress2WordPress Dashboard controls the contents and settings of a blog. It’s easy to add a widget in WordPress Dashboard, if you want to post a notice to a specific group of users. It’s also useful if you’re a Theme Developer and want to add a specific widget about Theme support on the Dashboard. Adding a custom widget is simple. Just open your functions.php and add the following code:

[PHP]
if(current_user_can(‘subscriber’)){
add_action(‘wp_dashboard_setup’, ‘subscriber_dashboard_widgets’);
}
function subscriber_dashboard_widgets() {
global $wp_meta_boxes;
wp_add_dashboard_widget(‘custom_help_widget’, ‘WIDGET TITLE’, ‘custom_dashboard_widget’);
}
function custom_dashboard_widget() {
echo ‘<p>ADD YOUR MESSAGE HERE. ADD A PARAGRAPH TAG FOR A NEW LINE.</p>';
}
[/PHP]

If you want to display the widget only to your contributors or authors change the word “subscriber” on line 1. You can change the widget title on line 6 and you can add your custom message on line 9.
Dashboard
Your contributor will see something like the above image. If you have any problem installing the code, just leave a comment below and I will help you out.

Article by »


Sahil is the Editor of iBlognet. He is a freelance writer on topics related to Website Optimization (SEO), Blogging, and Tech. He also specializes in SEO, HTML, CSS and Photoshop. Sahil has written 294 fantastic article(s) on iBlognet.


Author Site » Know me More

Author Connect »

Comments on this entry are closed.

Previous post:

Next post: