Skip to:
Content
Pages
Categories
Search
Top
Bottom

would it be possible to filter out two different user types?

  • @flamuren

    Participant

    Hi,

    I love buddypress and wpjm combo. Its free and helps people get jobs, which is my private project.

    However I am not so tech savy and not any real coding.

    My question is if its possible, within reason, to add two choices on the member page, to filter out two user classes/types (wpjm candidates and employers).

    Today I have active members and “my friends” as tabs and also a search member field under that. I would like to add candidates and employers, to filter out those users. Mainly employers – since it woud be nice for candidates to reach out if it seems good match.

    I guess find the teamplate for members, add it to my child theme and ad buttons, and then connect the buttons with a filter option in the child theme function file?

    Best regards,

    Flamur

Viewing 1 replies (of 1 total)
  • @flamuren

    Participant

    I wrote this code in the child function file but it wont work. Any suggestion what might be wrong?

    function my_custom_bp_employer_features_setup() {
        add_action( 'bp_members_directory_tabs', 'my_custom_members_directory_employer_tab', 10 );
        add_filter( 'bp_pre_user_query_args', 'my_custom_members_directory_filter_by_role' );
        add_action( 'wp_head', 'my_custom_members_directory_employer_tab_styles' );
    }
    add_action( 'bp_loaded', 'my_custom_bp_employer_features_setup' );
    
    function my_custom_members_directory_employer_tab() {
        error_log( 'my_custom_members_directory_employer_tab: Attempting to add "Arbetsgivare" tab.' );
        if ( ! function_exists( 'buddypress' ) || ! bp_is_active( 'members' ) ) {
            error_log( 'my_custom_members_directory_employer_tab: BuddyPress or Members component not active.' );
            return;
        }
        bp_members_add_tab( array(
            'id'                => 'employer',
            'text'              => __( 'Arbetsgivare' ),
            'slug'              => 'employer',
            'link'              => bp_get_members_directory_permalink() . 'employer/',
            'position'          => 35,
            'css_id'            => 'members-employer-tab',
            'screen_function'   => 'my_custom_members_directory_employer_screen',
            'show_in_filters'   => true,
            'filter_id'         => 'employer',
        ) );
        error_log( 'my_custom_members_directory_employer_tab: Successfully called bp_members_add_tab().' );
    }
    
    function my_custom_members_directory_employer_screen() {
        error_log( 'my_custom_members_directory_employer_screen: Screen function called.' );
        bp_core_load_template( 'members/index' );
    }
    
    function my_custom_members_directory_filter_by_role( $query_args ) {
        error_log( 'my_custom_members_directory_filter_by_role: Filter applied.' );
        if ( bp_current_action() === 'employer' ) {
            error_log( 'my_custom_members_directory_filter_by_role: Filtering by "employer" role.' );
            $query_args['role'] = 'employer';
        }
        return $query_args;
    }
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar