Support » Plugin: WooCommerce » Admin Bar hidden for bbPress Moderators after 4.6.1 update

  • Resolved samtime

    (@samtime)


    Hi, After updating WooCommerce to ver 4.6.1 , my bbPress moderators can no longer access the WordPress Admin panel to moderate the forum.

    When I deactivated the WooCommerce plugin, the admin bar reappeared for moderators. And when I reactivate WooCommerce, it disappeared.

    I used the following code in my theme’s functions.php file, which used to fix the issue, however it does not seem to work since the latest WooCommerce update:

    add_action('init', function(){
    if(class_exists('WooCommerce') && function_exists('bbp_get_user_role') && is_user_logged_in()){
    
    $current_user = wp_get_current_user();	
    $user_id = $current_user->ID;	
    $bbp_get_user_role = bbp_get_user_role($user_id);
    
    if($bbp_get_user_role == 'bbp_keymaster' || $bbp_get_user_role == 'bbp_moderator'){	
    add_filter( 'woocommerce_prevent_admin_access', '__return_false' );
    add_filter( 'woocommerce_disable_admin_bar', '__return_false' );
    }
    }
    });

    Any ideas on how I could edit the code so that the Admin Bar will show up again for bbPress moderators (or another solution)?

    Thank you, Sam

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    Hi there,

    This is a fairly complex development topic. Iā€™m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Plugin Support Jess – a11n

    (@jlundie)

    Hi @samtime,

    This thread has been inactive for quite a while, so I’m going to mark this as resolved. If you have any further questions, feel free to start a new thread šŸ™‚

    Thread Starter samtime

    (@samtime)

    Yes, got the following solution from a friend and it seems to work!
    Posting the updated code here incase others have the same problem:

    add_filter('woocommerce_disable_admin_bar', '_wc_disable_admin_bar', 10, 1);
     
    function _wc_disable_admin_bar($prevent_admin_access) {
        if (!current_user_can("keymaster") && !current_user_can("bbp_moderator") ) {
            return $prevent_admin_access;
        }
        return false;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Admin Bar hidden for bbPress Moderators after 4.6.1 update’ is closed to new replies.