Skip to:
Content
Pages
Categories
Search
Top
Bottom

Message Privacy Options


  • livingflame
    Participant

    @livingflame

    Hi there. I think this code ==> is very userful, but, can be better.
    How can I add options to choice from Profile / Settings:

    [√] Everyone (marked by default)
    [ ] Only friends

    // Restrict Private Message 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' );


    @r-a-y


    @shanebp

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar