Skip to:
Content
Pages
Categories
Search
Top
Bottom

Blocking some logged-in users from accessing buddypress altogether


  • goofydoo
    Participant

    @goofydoo

    I’m wondering if we can block some logged-in users from accessing BP entirely based on user role, or any other means?

    I use WooCommerce Subscription extension and it assigns users with an inactive subscription to Customer user role . So I’m hoping to block these users from accessing BP altogether.

    Thank you.

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

  • Peter Hardy-vanDoorn
    Participant

    @petervandoorn

    This should do the trick:

    function bgmc_nosubs_redirect() {
    	
    	if ( current_user_can( 'Customer' ) && is_buddypress() ) {
    		wp_redirect( home_url( '' ) ); 
    		exit();
    	}
    
    }
    add_filter( 'template_redirect', 'bgmc_nosubs_redirect' );
    

    Note – untested, but theory is sound 🙂


    goofydoo
    Participant

    @goofydoo

    Hi Peter,

    I pasted the codes to my functions.php but they did not help. I appreciate your help. 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar