Don’t show users in New Message TO dropdown if messages not allowed by user


Home Forums Front End PM PRO Don’t show users in New Message TO dropdown if messages not allowed by user

This topic is: Resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #41438
    jilllynndesign
    Participant

    Hi! When trying to send a message to a user who has unchecked “Allow others to send me messages?” it still shows their name in the TO dropdown.

    After sending the message, I see:
    Error: (user) does not want to receive messages!
    Error: You must enter valid recipient!

    Is there a way to show this when someone selects the user in the TO field so they don’t have to type out a message only then to see the error?

    Or can the user not appear in the New Message dropdown if they’ve unchecked “Allow others to send me messages?”

    #41453
    Shamim Hasan
    Keymaster

    You can add following code in your theme’s (child theme’s if you are using) functions.php. It will hide those users from autosuggestion who unchecked “Allow others to send me messages?” in their settings.

    add_filter( 'fep_filter_rest_users_args', function( $args, $for, $q, $x ) {
    	$args['meta_query'] = [
    		'relation' => 'OR',
    		[
    			'key' => 'FEP_user_options',
    			'value' =>  's:14:"allow_messages";s:1:"1";',
    			'compare' => 'LIKE',
    		],
    		[
    			'key' => 'FEP_user_options',
    			'compare' => 'NOT EXISTS',
    		]
    	];
    	return $args;
    }, 10, 4 );
    
    #41459
    jilllynndesign
    Participant

    That worked perfectly. Thank you!!

Viewing 3 posts - 1 through 3 (of 3 total)

You need to purchase ‘Front End PM PRO’ to create topic in this support forum.

If you already purchased ‘Front End PM PRO’ please LOGIN.