I have been trying and searching to accomplish this. I have the "custom menu" widgets "Members Area", "Admin Area" in side bar, assigned menus to them. Fine, they display.

I want to show "Admin Area" widget only when the current user is admin. I believe it has something to do with adding a filter to "sidebars_widgets". Honestly, i do not have a clue to target the "Admin Area" widget. How do I handle this ?

2 Answers 2


you can use Dynamic Widgets plugin to achieve this. It is free and is available in WordPress plugins repository.

  • Thank you Vinod, but i do want to avoid additional plugins wherever possible. How do I attack the specific "Custom Menu" widget (, and i have more than one) in sidebar ? Apr 3, 2013 at 5:51

The most robust way is to "fork" the core widget and add whatever logic you require (in this case, check which user is logged-in before outputting anything). Just locate the code in core, copy it, at your on relevant hooks on widgets_init to register it and make whatever changes you need.

While, as @vinod indicated in his answer, it is possible to filter out widgets from being displayed in a sidebar, since you will most likely need to hardcode the id of the widget, IMO it results in an harder to maintain code, and the somewhat longer alternative presented above is better for the long term maintenance of your code.

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.