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:

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>';
}

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 founder and 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 277 fantastic article(s) on iBlognet.


Author Site » Know me More

Author Connect »

{ 4 comments… read them below or add one }

1 Obasi Miracle

I implemented this few hours ago in one of my friend’s my blog to say the least your code worked like a charm.

One more thing how can I remove the gravatar part?
Obasi Miracle invites you to read Download Kingsoft Office Professional v8.1My Profile

Reply

2 Sahil Umatia

Gravatar Part?? From where??
Sahil Umatia invites you to read Should You Advertise on Social Media Sites?My Profile

Reply

3 Nishadha

Thanks for this great article. I was looking to do something like this in some of my blogs for users with contributor rights. Hopefully I can use this code to implement this.
Nishadha invites you to read Creative Programming QuotesMy Profile

Reply

4 TrendyWp

This is working very well, Thanks
TrendyWp invites you to read XMarketMy Profile

Reply

Leave a Comment

We're glad that you chose to leave a comment. This blog uses KeywordLuv. Enter YourName@YourKeywords in the "Name" field to take advantage of link juice for your anchor text. Please keep in mind that all comments are moderated. Let's have a meaningful conversation.

CommentLuv badge
This blog uses premium CommentLuv Premium which allows you to put your keywords with your name if you have had 1 approved comments. Use your real name and then @ your keywords (maximum of 2)

Previous post:

Next post: