Reply To: Add custom filtering on users based on ACF Field


Home Forums Front End PM PRO Add custom filtering on users based on ACF Field Reply To: Add custom filtering on users based on ACF Field

#41348
Shamim Hasan
Keymaster

As i understand you want to restrict message sending between users based on some custom value of each user.
You can use following code

add_filter( 'fep_current_user_can', function( $can, $cap, $id ){
    if ( 'send_new_message_to' != $cap || ! is_user_logged_in() || fep_is_user_blocked() ) {
	return $can;
    }
    //Here check your custom value.
    //sender user id = get_current_user_id()
    //receiver user id = $id
    //return true if this sender can send to this receiver
    //return false if this sender can not send to this receiver
}, 10, 3);