Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Settings to show WP admin Bar on Front End #6644
    wbonadmin
    Participant

    I’ve isolated the source of the problem to the “BuddyBoss” plugin. It is built on the BuddyPress framework. So I’ll see what I can find out about how it controls admin toolbar access and what I need to change. Any suggestions would be welcome.

    Also, is there a way to direct the “membership_manager” to the frontend of the site (which will have the toolbar available, rather than the WP Admin backend?

    in reply to: Settings to show WP admin Bar on Front End #6639
    wbonadmin
    Participant

    Thanks so much for your response.

    I added the code as written above — “code for membership_manager,” using “Code Snippets” Plugin rather than typing directly into functions php file. Deactivated the site – Said there was a “parsing error on line 8”

    add_filter( 'woocommerce_disable_admin_bar', '_wc_disable_admin_bar', 10, 1 );
    function _wc_disable_admin_bar( $disable ) {
     
        $user = wp_get_current_user();
        if ( !is_a( $user, 'WP_User') || !is_array( $user->roles ) ) {
            return $disable;
        }
        if ( !in_array( 'membership_manager', $user->roles ) {
            return $disable;
        }
    
        return false;
    }

    I deleted that snippet and as an alternative, copied code from the referenced article and substituted my role name; did not work as desired: does not show admin toolbar on front end for the selected role.

    add_filter('woocommerce_disable_admin_bar', '_wc_disable_admin_bar', 10, 1);
     
    function _wc_disable_admin_bar($prevent_admin_access) {
        if (!current_user_can('membership_manager')) {
            return $prevent_admin_access;
        }
        return false;
    }
     
    add_filter('woocommerce_prevent_admin_access', '_wc_prevent_admin_access', 10, 1);
     
    function _wc_prevent_admin_access($prevent_admin_access) {
        if (!current_user_can('membership_manager')) {
            return $prevent_admin_access;
        }
        return false;
    }

    What am I doing wrong?

Viewing 2 posts - 1 through 2 (of 2 total)