Skip to:
Content
Pages
Categories
Search
Top
Bottom

disable private messaging for specific user

  • @hotconductor

    Participant

    I have a small forum where most people PM left n right. Fun group. However, one particular user is being problematic. We would like to be able to disable that user’s ability to send PMs, but not ban them etc. Note: I do NOT want to install that ‘PM for friends only’ plugin. People want to be able to send/receive private messages freely.

    To reiterate… How can I remove PM privileges for one specific user?

Viewing 5 replies - 1 through 5 (of 5 total)
  • @shanebp

    Moderator

    You could use this action hook, found in :
    buddypress\bp-messages\classes\class-bp-messages-message.php
    do_action_ref_array( 'messages_message_before_save', array( &$this ) );

    Untested, but try:

    function block_the_jerk( $message_info ) {
    
       if( $message_info->sender_id == 666 )  // change 666 to jerk's user_id
           unset( $message_info->recipients );
    
       return $message_info;
    }
    add_action( 'messages_message_before_save', 'block_the_jerk');

    This should remove all recipients – causing the send message function to return false.
    I’m not sure what if any feedback the jerk will see.

    @hotconductor

    Participant

    are you saying I should try to apply that on class-bp-messages-message.php

    Never touch core files.
    Place the code in your theme/functions.php.

    @shanebp

    Moderator

    [ sorry, I hit Edit instead of Reply. See above. ]

    @hotconductor

    Participant

    Got it! BTW, can I put multiple user names there with , bewteen them?

    @shanebp

    Moderator

    No, you need to use in_array for that

    $block_ids =  array( 666, 777 );
    
    if ( in_array( $message_info->sender_id, $block_ids ) ) 
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘disable private messaging for specific user’ is closed to new replies.
Skip to toolbar