Add custom filtering on users based on ACF Field


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

This topic is: Resolved
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #41344

    Hi everyone
    Need some support to find the right action/filter or, if not available, where to poke and add custom code.
    I’ve been able to configure the “role to role block” so users can only send messages to the roles i want.

    Wordpress users have an extra field (created with Advanced Custom Fields plugin) named Comitee that associates them to a given post (of custom type).

    How can i, along with the role to role block, force the filtering to chek for this cpt ID in order to allow the messages only between users of the same “group” or any other relation i want to set?

    Thank you in advance

    D.

    #41348
    shamim
    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);
    
Viewing 2 posts - 1 through 2 (of 2 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.