Ultimate Branding: Custom entry on Admin Bar for non-logged-in users

Hello,

is it possible to show my custom entry on Admin Bar also for non-logged-in users? Now it is only visible if user is logged in.

Thanks in advance for your reply.

Michal

  • Bojan Radonic

    Hey there Michal, hope you're well today!

    I don't believe this is possible out of a box with the current version of Ultimate Branding. You can only set the links for different user roles but not for visitors. By default it displays Log In and Register and you should be able to add another link there with some custom code.

    I've found the following snippet and tested it on my end and everything worked properly. Please try adding the following to your theme functions.php (ideally you'd want to add this to your child theme functions.php so it doesn't get removed when you update the theme)

    function pjw_login_adminbar( $wp_admin_bar) {
    	if ( !is_user_logged_in() )
    	$wp_admin_bar->add_menu( array( 'title' => __( 'Link Text' ), 'href' => 'http://example.com' ) );
    }
    add_action( 'admin_bar_menu', 'pjw_login_adminbar' );
    add_filter( 'show_admin_bar', '__return_true' , 1000 );

    Replace Link Text and the dummy URL with the actual text of the link and the URL where you want this to link to.

    Please let me know if this helps :slight_smile:

    Best regards,
    Bojan