I need to add a link to the drop-down user menu in the admin bar. Is there a hook or function for this?

WP admin bar user drop-down menu


You want to use $wp_admin_bar->add_node( $args ).

Below is a tested working example.

function wpse_add_toolbar_edit($wp_admin_bar) { 
    $wp_admin_bar->add_node( array(
        'id'        => 'mylink',
        'title' => 'My New Link',
        'href' => 'mailto:support@domain.com',
        'parent' => 'user-actions'
    ) );

add_action('admin_bar_menu', 'wpse_add_toolbar_edit', 999);

Note: The parent param adds the link to an existing ID. If you need to find the correct ID to add your new link to you can var_dump($wp_admin_bar); and look through the output for the correct ID.

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.