Reply To: Add custom filtering to DIRECTORY LISTING based on ACF Field


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

#41521
evaristo g..daporta
Participant

Nevermind, i figured it out:

Solution:

add_filter( 'fep_directory_arguments', function ($args){
                $user = wp_get_current_user();
                $role = $user->roles[0];
                if( $role == 'delegate'){
                    $meta_query = array();
                    $comitee_post= get_field( 'comitee', 'user_'.$user->ID);
                    $meta_query  = array(
                        'relation' => 'AND',
                        array(
                            'key' => 'comitee',
                            'value' => $comitee_post->ID,
                            'compare' => '='
                        ),
                    );

                    $args['meta_query']	=   $meta_query;
                }
                return $args;
            }, 99);

Hope it helps anyone!