BuddyDev

Search

Disable Private Message Function of specific User Role

  • Participant
    Level: Enlightened
    Posts: 146
    Dandy Jefferson on #6387

    Hi,

    Thanks for your previous helps and I’m appreciated about that.

    I met an issue about how to disable Private Message Function for specific User Role in the BuddyPress.

    For example, I want to disable Private Message Function of “Blogger” in my site, restricting them to send any private messages to anyone else in the system, but they can still receive messages from other users.

    I’m wondering that is it possible to do that? Could you give me some code snippets about that?

    Thank you very much.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2499
    Ravi on #6388

    Hi Dandy,

    Please install our plugin “BuddyPress Private Message Rate Limiter” and Try the following code in your “bp-custom.php” file. I don’t understand blogger role. Please check appropriate capability reference here

    https://codex.wordpress.org/Roles_and_Capabilities

    
    
    function buddydev_disable_private_messaging_for_blogger( $allowed_count ) {
    
    	if( current_user_can( 'create_sites' ) ) {
    		//should we change it?
    		//if yes, change for super admin
    	} elseif( current_user_can( 'list_users' ) ) {
    		//site admin or above
    	} elseif( current_user_can( 'publish_pages' ) ) {
    		//editor or above
    	} elseif( current_user_can( 'edit_published_posts' ) ) {
    
    	} elseif ( current_user_can( 'edit_posts' ) ) {
    		//contributor or above
    	} elseif ( current_user_can( 'read' ) ) {
    		//subscriber or above
    		$allowed_count = 0;
    	}
    
    	return $allowed_count;
    }
    add_filter( 'bp_rate_limit_pm_remaining_count', 'buddydev_disable_private_messaging_for_blogger' );
    
    

    Thank You
    Ravi

    • This reply was modified 6 years ago by Ravi.
    • This reply was modified 6 years ago by Ravi.
  • Participant
    Level: Initiated
    Posts: 2
    Travis on #33883

    How could you do this for specific groups?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2499
    Ravi on #33890

    Hello Travis,

    Thank you for posting. Please let me know are you refering to BuddyBoss Group messages?.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 2
    Travis on #33896

    Hi Ravi,

    Thanks for the quick reply!

    I have several “Private” groups established with various nested groups utilized for Learndash courses. Some of the groups are general in nature for as a container for organic customers. Other groups are for students associated with Organizations that each group acts as a “container” to separate one from the other. Some of the groups should be allowed to use the private messaging & group forums, other groups I want to be able to turn off the private messaging and restrict communication to just the group forums (and email for group leaders).

    Using the BP Private Message Rate Limiter, could it be adapted to manage this?

    Thank you,
    Travis

  • Keymaster
    (BuddyDev Team)
    Posts: 22211
    Brajesh Singh on #33932

    Hi Travis,
    I am assuming that you are using BuddyBoss platform as the private message for groups in only available with it currently.

    Can you please open a new topic an provide us the following details:-

    1. Do you want restrictions for group message tab only?
    2. Which role should be able to see the message tab in group(moderators/group admins/members)
    3. Or do you simply want to turn on/off the group message based on group?

    Thank you
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved