Forum: WP Users Geolocation

This forum is closed for new topics. However, you can still search for a solution in the old topics. For technical support related to the WP Users Geolocation premium extension please open a new premium support ticket.

[Resolved]Can WP User Geolocation search according to wp profile role?

Home Forums WP Users Geolocation Can WP User Geolocation search according to wp profile role?

This topic contains 7 replies, has 4 voices, and was last updated by  norfolkandway 2 years, 1 month ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #31610

    marcsarin
    Participant

    Can I search users according to their wordpress role with WP Users Geolocation? For example I only want to show wp profiles that have the role of customers only or the role of vendors only.

    #31613

    Eyal Fitoussi
    Keymaster

    Hello Marcsarin,
    The feature is not available via UI but you can easily filter Search results ( of GEO my WP’s WP Users form ) based on user role using filters provided by the plugin.

    #31612

    marcsarin
    Participant

    Thanks for the info. I bought the plugin. So how do I filter to show results for vendors role only?

    #31611

    Eyal Fitoussi
    Keymaster

    Thank you for the purchase Marcsarin.

    Add the code below to the functions.php file of your theme and modify it based on your needs ( the form ID and user role as noted in the script ):

    #50816

    Eyal Fitoussi
    Keymaster

    This topic marked “Resolved” due to inactivity. If you wish to reply to this topic please change its status to “Not resolved”  before replying.

    #53599

    Phill Healey
    Participant

    Sorry for tagging on to an existing thread….

    How can we use this code to exclude more than one user role?

    #53600

    Phill Healey
    Participant

    I actually meant to show more than one user role (eg show only ‘editor’ & ‘subscriber’ roles but exclude all others).

    #56398

    norfolkandway
    Participant

    HI
    I am attempting to achieve this on my site –
    Submit search result returns only members with role of ‘Vendor’
    At present all members that have added their address/location are returned in search results.

    before I add this code in functions.php can you please tell me
    1 – It looks like the code excludes user roles 10
    2 – Displays Editor only
    In the code
    //enable advanced query
    add_filter( ‘gmw_ug_advanced_query_class’, ‘__return_true’ );

    function gmw_exclude_users_by_role( $gmw ) {

    //use the filter only for a specific form. Change the value 1 to your form ID
    if ( $gmw[‘ID’] == 1 ) {
    //Filter results based on Editor role. Modify it based on your needs
    $gmw[‘query_args’][‘role’] = ‘Editor’;
    }
    return $gmw;
    }
    add_filter( ‘gmw_ug_form_before_users_query’, ‘gmw_exclude_users_by_role’, 10 );

    I am a bit confused over what this code displays/excludes, Could you please explain?

    Thanks
    iain

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.