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.

Managing user meta

Home Forums Community Forum Managing user meta

This topic contains 1 reply, has 2 voices. Last updated by  Jason (Lead Developer) 3 years, 11 months ago.

Topic Author Topic
Posted: Thursday Jan 17th, 2013 at 4:46 pm #37941

We’ve developed a custom reports plugin, which uses s2 member meta fields (we have roughly 100 fields per user, and 7000 users) – due to the storage of s2 meta (serialized arrays in a DB), we can’t effectively search across them without inaccurate(i.e. – doing a LIKE won’t work) or extremely long running queries (selecting and looping through PHP side), as such we’ve resorted to storing the s2 user meta into the wp_usermeta table as well – while this seems absurd to store it in two places, it’s allowed us to query the data much more efficiently, unfortunately we’ve found a few cases where the user meta does not match the s2 user meta, so there must be some way s2 is updating/inserting that we’re not catching. These are the current hooks we use to duplicate the s2 usermeta into actual user meta:
‘ws_plugin__s2member_during_configure_user_registration_front_side’
‘ws_plugin__s2member_during_configure_user_registration_admin_side’
‘ws_plugin__s2member_after_handle_profile_modifications’
‘ws_plugin__s2member_during_users_list_update_cols’

Are there any other hooks that we can use to be absolutely sure when an s2 user meta field gets added or updated, we add it to regular wp usermeta?

Thanks!

List Of Topic Replies

Viewing 1 replies (of 1 total)
Author Replies
Author Replies
Posted: Saturday Jan 19th, 2013 at 9:58 pm #38363
Staff Member

Thanks for your inquiry. ~ We appreciate your patience :-)

Are there any other hooks that we can use to be absolutely sure when an s2 user meta field gets added or updated, we add it to regular wp usermeta?

I’m sorry, I can’t offer any filters for this. This is not something that filters are designed to handle (i.e. synchronizing DB column values). Even if you found a way to capture every single possibility, it’s likely to change from one release of the software to the next.

Just to point out. While certainly NOT ideal, it IS possible to search serialized data as it exists already. Please see the example below, where we use MySQL’s REGEXP search.

Ex: `meta_value` REGEXP '.*\"country_code\";s:[0-9]+:\"US\".*'

<?php
global $wpdb;
$users = $wpdb->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 = new WP_User ($user->ID); // Get full User object now.
                print_r($user); // Get a full list of properties when/if debugging.
            }
    }
Viewing 1 replies (of 1 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.