Skip to:
Content
Pages
Categories
Search
Top
Bottom

Disable Private Messaging TO Specific Users


  • juliahart18
    Participant

    @juliahart18

    Hello, I need help please.

    I have seen many questions similar to this dating back 6 years. lol

    But hopefully, someone out there can help me.

    What I would like to do is allow members to send private messages to whoever they want in the community except a few Admins.

    I am not sure if there is a separate plugin that can do this. It would be easier if there was a profile setting where I as an Admin can turn receiving messages off but I have not seen that option.

    Thanks in advance.

Viewing 1 replies (of 1 total)

  • Henry Wright
    Moderator

    @henrywright

    Try this:

    function juliahart18_filter_message_recipients( $message ) {
        $i = 0;
        foreach ( $message->recipients as $recipient ) {
            // 1 is the ID of the user you want to exclude from the message.
            if ( $recipient->user_id == 1 ) {
                unset( $message->recipients[$i] );
            }
            $i++;
        }
    }
    add_action( 'messages_message_before_save', 'juliahart18_filter_message_recipients' );

    Please note I haven’t tested.

Viewing 1 replies (of 1 total)
  • The topic ‘Disable Private Messaging TO Specific Users’ is closed to new replies.
Skip to toolbar