BuddyDev

Search

[Resolved] How to disable public and private messages for specific users

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #18485

    Thank you Tosin.

    I am glad the code worked.

    1. Yes, It is still possible to send the message. We have only removed the button.

    I don’t see any way to completely restrict from receiving. If we use filter ‘bp_activity_do_mentions’ it will disable for all users.

    We can use it for disabling mention for the sender though(It won’t send notifications etc, but the user can manually mention and it will appear in the mention stream).

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #18495

    Hello Brajesh,

    I know and understand that you don’t provide support for 3rd party plugins, but I really need to impose on you for the last time since the code you provided works. I’m stuck will the code you provided work for this plugin https://wordpress.org/plugins/bp-profile-message-ux/

    Please I really really need this, I would be very gratefull

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #18506

    Hi Tosin,
    I will help you. Please allow me a few days to check the plugin.

    Thank you
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #18578

    Will be expecting your feedback sir

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #18586

    Hi Tosin,
    I haven’t been able to use the Message UX plugin yet. I will need a few more days before looking into it.

    Thank you
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #23508
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #23523
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #23557

    Hello Tosin,

    Please check the following code. remove the older code and let me know if it works or not.

    
    
    function buddydev_is_user_restricted( $user_id ) {
    	// These user's won't be able to send the message.
    	$restricted_user_ids = array( 2, 4766812, 4766806, 4766824, 4766786, 4766838 );
    
    	return in_array( $user_id, $restricted_user_ids );
    }
    
    function buddydev_start_buffering() {
    
    	if ( ! function_exists( 'bp_profile_messages_ux_init_pro' ) || ! buddydev_is_user_restricted( bp_displayed_user_id() ) ) {
    		return;
    	}
    
    	ob_start();
    }
    add_action( 'bp_member_header_actions', 'buddydev_start_buffering', 19 );
    
    function buddydev_end_buffering() {
    
    	if ( ! function_exists( 'bp_profile_messages_ux_init_pro' ) || ! buddydev_is_user_restricted( bp_displayed_user_id() ) ) {
    		return;
    	}
    
    	ob_get_clean();
    }
    add_action( 'bp_member_header_actions', 'buddydev_end_buffering', 21 );
    
    

    This will work in legacy.

    Regards
    Ravi

    • This reply was modified 5 years, 6 months ago by Ravi.
  • Participant
    Level: Guru
    Posts: 900
    Tosin on #23559

    OMG your code worked perfectly i’m very grateful. Thank you very very much

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #23573

    Thank you for the acknowledgement. I am glad that I could help.

    Regards
    Ravi

The topic ‘ [Resolved] How to disable public and private messages for specific users’ is closed to new replies.

This topic is: resolved