0

I have used add_action('admin_bar_menu', 'modify_admin_bar') to change the admin bar on the "front end" of WordPress (the site the user sees). However, it seems that modify_admin_bar() is not called before the admin bar is rendered on the "back end" (the Dashboard or admin side of WordPress).

How can I modify the admin bar as it is presented on the admin side of WordPress?

Here's an example...

add_action( 'admin_bar_menu', 'modify_admin_bar', 95 );
function modify_admin_bar() {
    error_log('admin barring');
}

In this example, my error log shows "admin barring" every time I refresh a page on the user side of WordPress, but never shows "admin barring" when I refresh the admin side (the Dashboard) of WordPress. It does not seem that the function gets called from the admin side. I am running WP 3.5.

  • Please show us the whole function, admin_bar_menu is called very late and works by default for front-end and admin. – Wyck Dec 12 '12 at 5:28
  • I have just confirmed the same behavior in a WP 3.4.2 site. There is clearly something I don't understand about the admin_bar_menu action. – EFC Dec 12 '12 at 15:42
0

Blush... the answer turned out to be a bit obvious...

The function error_log() was writing to two different logs on my system. One log was showing the errors when on user-facing pages, another log was showing errors on admin pages.

The plugin was working just fine, but I was not looking at the admin error log. Oops!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.