Skip to:
Content
Pages
Categories
Search
Top
Bottom

changing buddypress error message


  • david22c
    Participant

    @david22c

    Hi,
    Would someone be kind enough to help me with changing a buddypress error message? (wordpress 4.9.8, buddypress 3.1.0)

    I am restricting private messaging to user’s friends/connections. Currently, the error message returned when sending a private message to someone not in your network is “Message not sent. Please try again.” which doesn’t make sense. I would like it to say something like, “Sorry, you can only send a private message to connections in your network.” How might I change this error message?

    I have been using the following code in child functions to restrict private messaging:

    // if not site admin, restrict PMs to friends
    function pp_check_message_recipients( $message_info ) {
    
    //  site admins are not restricted
    if ( is_super_admin() )
    return $message_info;
    
    $recipients = $message_info->recipients;
    
    $friend_ids = friends_get_friend_user_ids( bp_displayed_user_id() ); 
    
    $nf = 0; 
    
    foreach ( $recipients as $key => $recipient ) {
    
    if ( ! in_array( $recipient->user_id, $friend_ids ) ) 
    $nf++;
    
    }
    
    // if any recipients are not friends, remove everyone from the recipient's list
    if (  $nf > 0 ) 
    unset( $message_info->recipients );
    
    return $message_info;
    }
    add_action( 'messages_message_before_save', 'pp_check_message_recipients' );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar