WordPress.org

Ready to get started?Download WordPress

Forums

WP User Frontend
[resolved] Wp-Admin bar for logged in users dissappears (5 posts)

  1. sassafrascal
    Member
    Posted 1 year ago #

    I have installed your plugin and love it very much - but I am having an issue. In my functions.php file I have a bit of code for logged out and logged in users to see two different customized admin bars. When I installed your plugin it stopped the logged in users being able to view the admin bar. But not the logged out users

    I would really like to use your plugin as it is the best I have seen. But logged in users must have the ability to see the admin bar as it is set to be there email and message bar.

    I uninstalled your plugin to get my admin bar back for them but it is still gone. I don't know why it is permanent even after the uninstall.

    Have you heard of this before or have a suggestion to correct it?

    http://wordpress.org/extend/plugins/wp-user-frontend/

  2. professor99
    Member
    Posted 1 year ago #

    I haven't heard of this before. Please post the code you are using to do this in functions.php and we might be able to see what is causing it.
    Strange the problem persists after deactivating WPUF. This would point to another plugin causing this problem so I would deactivate all other plugins first to see if this fixes the problem.

  3. sassafrascal
    Member
    Posted 1 year ago #

    I have been running the other plugins for months it did not happen until this plugin, but I will test it out - I noticed while investigating further that it was only making the Admin bar disappear for me and only on the frontend (admin) until I tested the plugin with a test user account and changed my password through the WPUF edit profile page. Suddenly the test user account did not have access to the admin bar either.

    Here is the code I use for logged in and logged out users. all worked well until the plugin - something is interfering but I have no idea what.

    /*
    * Remove the WordPress Logo from the WordPress Admin Bar
    */
    function remove_wp_logo() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('wp-logo');
    }
    add_action( 'wp_before_admin_bar_render', 'remove_wp_logo' );

    /*
    * Disable the Search Icon and Input within the Admin Bar
    */
    function disable_bar_search() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('search');
    }
    add_action( 'wp_before_admin_bar_render', 'disable_bar_search' );

    /*
    * Move the Login Link from the left side to the right side within the Admin Bar for logged out users.
    */
    function move_login_link() {
    $move_login_link = '<style type="text/css">
    #wpadminbar #wp-admin-bar-bp-login{float:right}
    }
    </style>';
    echo $move_login_link;
    }
    add_action( 'wp_head', 'move_login_link' );

    /*
    * Move the Register Link from the left side to the right side within the Admin Bar for logged out users.
    */
    function move_register_link() {
    $move_register_link = '<style type="text/css">
    #wpadminbar #wp-admin-bar-bp-register{float:right}
    }
    </style>';
    echo $move_register_link;
    }
    add_action( 'wp_head', 'move_register_link' );

    /*
    * Create a menu for Logged Out Users
    */
    function loggedout_menu( $meta = TRUE ) {
    global $wp_admin_bar;

    $wp_admin_bar->add_menu( array(
    'id' => 'home',
    'title' => __( '<img src="/wp-content/images/design/home_icon.png" width="25" height="25" />' ),
    'href' => 'http://gloconj.com',
    'meta' => array( target => '_self' ))
    );

    $wp_admin_bar->add_menu( array(
    'id' => 'Facebook',
    'title' => __( '<img src="/wp-content/images/design/facebook_icon.png" width="25" height="25" />' ),
    'href' => 'http://www.facebook.com/GloCoNewJersey',
    'meta' => array( target => '_blank' ))
    );

    $wp_admin_bar->add_menu( array(
    'id' => 'Google',
    'title' => __( '<img src="/wp-content/images/design/google_icon.png" width="25" height="25" />' ),
    'href' => 'https://plus.google.com/111021982656964237446/posts',
    'meta' => array( target => '_blank' ))
    );

    $wp_admin_bar->add_menu( array(
    'id' => 'Twitter',
    'title' => __( '<img src="/wp-content/images/design/twitter_icon.png" width="25" height="25" />' ),
    'href' => 'http://twitter.com/#!/Gloconj',
    'meta' => array( target => '_blank' ))
    );

    $wp_admin_bar->add_menu( array(
    'id' => 'YouTube',
    'title' => __( '<img src="/wp-content/images/design/youtube_icon.png" width="25" height="25" />' ),
    'href' => 'http://www.youtube.com/user/GloCoNJ',
    'meta' => array( target => '_blank' ))
    );

    $wp_admin_bar->add_menu( array(
    'id' => 'Pinterest',
    'title' => __( '<img src="/wp-content/images/design/pinterest_icon.png" width="25" height="25" />' ),
    'href' => 'http://pinterest.com/GloCoNJ/',
    'meta' => array( target => '_blank' ))
    );

    }
    add_action( 'admin_bar_menu', 'loggedout_menu', 15 );

  4. professor99
    Member
    Posted 1 year ago #

    The only thing that I can think of in WPUF that may be causing your problem is the option 'Admin area access'. Try disabling this to see if it solves your problem.

    Im thinking $wp_admin_bar->remove_menu('wp-logo') removes the admin bar for the duration of your session hence why it persists despite the deactivation of WPUF.

    I do a similar thing but without problems as follows. Try this and see if it fixes your problem.

    global $user_login;
    get_currentuserinfo();
    
    /* Hide admin bar for non-admins */
    if ( $user_login != 'admin' ) {
    	add_filter( 'show_admin_bar', '__return_false' );
    }
  5. sassafrascal
    Member
    Posted 1 year ago #

    Thank you - I am not a PHP coder so I am flying blindly with this... I added your code and changed __return_false to __return_true - because I do want logged out users to see the menu and it seems to have worked.

    Thank you so much - It means a lot when folks like you help WordPress novices like me! I appreciate your time :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags