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]Custom User Filters

Forums WP Users Geolocation Custom User Filters

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #46109
    Ryan Town
    Member

    Can you tell me how we can make a keyword filter, or a custom filter for the user search forms, that would allow is to filter the users searched by a custom field id?

    We would like to build this to work similar to how the search forms for posts has the ability to drop down a category filter, but instead for Users. Please help!

    #46161

    Hello Ryan,

    This feature will require some custom coding. It should be possible if you know some PHP and how to use WordPress hooks.

    1) You need to add an INPUT field that will serve as the keywords field to the search form template file. You can do it using a hook or by inserting it directly to the template file. Give the field a name attribute such as gmw_keywords. The value of the field will pass to the URL using the name attribute you provided.

    2) Write a custom script that will filter the search results on form submission. On form submission you can get the keywords value via the URL. For example $_GET[‘gmw_keywords’] or whatever name attribute you provided the input field with.

    Now, your custom script really depends on what you need to filter ( user name, user meta, user role and so on ).
    You can use the hook

    ( gmw-users-geolocation/includes/gmw-ug-search-query-class.php )

    to filter the basic arguments that pass to the WP_User_Query which responsible for the users search query.

    Here you can get an idea of how to filter users using WP_User_query.

    i hope that helps.

    #46875
    Ryan Town
    Member
    Private Content Hidden
    #47054
    This reply has been marked as private.
    #48781

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

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

You must be logged in to reply to this topic.