latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

How to get Custom Fields searchable?

Home Forums Community Forum How to get Custom Fields searchable?

This topic contains 2 replies, has 3 voices. Last updated by  Bruce 3 years, 6 months ago.

Topic Author Topic
Posted: Saturday Jul 6th, 2013 at 4:05 am #53073
Username: jessika

I really like the s2member plugin thanks for that!

Before I’m going to buy the pro version I need to know if and how to get the s2member Custom Fields searchable.

At the moment I’m using the Buddypress plugin BP Search.
Sadly this plugin can’t search in the s2member custom fields.

Now I would like to create my own search to search the s2member custom fields.
But sadly I can’t get it done.

How can I get a User search with s2member custom fields?
I really need that working before I’m going to get s2member pro.
Would be great if you could give some help.

I already tried
But this post is already two years old.
Is there a easier solution yet?
If not could you help to describe one point more in detail?:

When I’m using the code like described in the post:

get_results ("SELECT `user_id` as `ID` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_custom_fields' AND `meta_value` REGEXP '.*"country_code";s:[0-9]+:"US".*'");
if (is_array ($users) && count ($users) > 0)
        foreach ($users as $user)
                $user = /* Get full User object now. */ new WP_User ($user->ID);
                print_r($user); /* Get a full list of properties when/if debugging. */

I get the the following output:

WP_User Object ( [data] => stdClass Object ( [ID] => 22 [user_login] => username1 [user_pass] => $D$ZTVBHJ6789VGHBJNKMK. [user_nicename] => username1 [user_email] => [user_url] => [user_registered] => 2013-06-27 02:55:06 [user_activation_key] => [user_status] => 0 [display_name] => username1) [ID] => 22 [caps] => Array ( [subscriber] => 1 ) [cap_key] => wp_capabilities [roles] => Array ( [0] => subscriber ) [allcaps] => Array ( [read] => 1 [level_0] => 1 [access_s2member_level0] => 1 [subscriber] => 1 ) [filter] => )

How can I use the code in a search field and how can I use that information and format it properly?

I would like to have for example to search fields:

After searching for one or both of this field I would like to get the Buddypress profiles listed that have this info in their s2member profile fields.
I just want the same functionality and result like the Buddypress Plugin BP Search.

I’m sure other people would be interested in these tips too.

Thank you

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Monday Jul 8th, 2013 at 5:02 pm #53127


I am not an S2member expert I am a fairly new user. I had a similar issue and here is how I resolved it with out coding. I installed Buddy Press and then installed amr users pro. These 2 together gave me the capability to use my custom fields created in s2member and create a search page where they can be searched by my users. If you go this route buddy press will ask you to set pages for these Activity Streams, User Groups, Activate, Register. I set all mine to none and default to s2member. Essentially I am only using buddypress as a gateway to turn my s2member profile fields into searchable fields. Then using amr user pro to search them. I also have bb press installed. Hope this helps. It worked for me.

Posted: Tuesday Jul 9th, 2013 at 4:19 am #53150
Username: Bruce
Staff Member

Thank you for your inquiry. I’m very sorry about the delay in response.

The problem you’re running into is a design flaw with s2Member we are looking to fix in the next major release of s2Member, which is a rewrite we’re hoping to have ready sometime soon.

Currently the only place I know of to point you to attempting to make this possible through code is the thread you already linked to. I can’t say I know everything that’s happening here but I can tell you that the syntax of the fields has NOT changed since then, and if the code worked then it should work now as well.

I can also tell you that the code you’re using is going to drastically slow down your search queries, because it’s picking up values from the usermeta database table as well as the user database table, and it’s use REGEX to find the value of the custom field with the slug country_code.

If the code is not working for you, I’d first make sure that the slug for the field you’re attempting to order by is in fact country_code. That looks like the best place to start looking for the error.

Viewing 2 replies - 1 through 2 (of 2 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.