Reply To: 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 › Reply To: Don’t show users in New Message TO dropdown if messages not allowed by user

#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 );