Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide/restrict access to Private Messaging

  • Avatar of rtandoh
    rtandoh
    Participant

    @rtandoh

    Hi

    I would appreciate some guidance re. programmatically restricting access to Private Messaging to paid subscribers (using the WooCommerce and Groups plugins).

    Any pointers as to where in the BuddyPress codebase to look would be appreciated.

    Richard

Viewing 4 replies - 1 through 4 (of 4 total)
  • Avatar of Henry
    Henry
    Participant

    @henrywright-1

    you would add something like this to your theme’s functions.php

    function bp_disable_messaging() {
    	global $bp;
    	
    	if ( USER_TO_DISALLOW && bp_is_current_component('messages') ) {
    		wp_redirect( home_url() );
    		exit();
    	}
    }
    add_action('wp','bp_disable_messaging');

    Note: USER_TO_DISALLOW would be your unpaid WooCommerce users. You would need to get whatever this was from WooCommerce as I’m not familiar with the plugin. Once you’ve added that bit in the code should work.

    Avatar of shanebp
    shanebp
    Moderator

    @shanebp

    @henrywright-1
    Don’t include the global if you aren’t going to use it.

    Avatar of Henry
    Henry
    Participant

    @henrywright-1

    @shanebp – oops thanks for pointing that out. global $bp; can be removed

    Avatar of rtandoh
    rtandoh
    Participant

    @rtandoh

    @henrywright-1, @shanebp

    Thank you very much. The code worked nicely, removing both the button and the functionality.

    rt.

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

You must be logged in to reply to this topic.