Support » Plugins » Adding two fields to the Registration form…

  • Don’t close this topic, as was done before here. It was not answered on the main board, specifically because I was told to post it over here:

    As my title says, I’d like to add two fields to my Registration Form that Insert to my MySQL database. I use a User Management plugin, s2member, to manage subscribers, and it’s just about perfect for my needs with the exception the custom registration fields it creates produces serialized data. I’m having a hard time dealing with that data.

    (Any time I ask for help with serialized data that WordPress produces, I usually have to argue through, “Why did you write it to do that?” — I didn’t.)

    I’m sort of worried if I use a plugin, it will be a touch bloated and not work well with my s2member. I’d just like to know what hook to link into, if it exists, where I can place a couple of questions. Is it wp_register?

    I’ve already added the columns in the Users data table. 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • To be specific, I’m not looking for a plugin or solution that takes over the registration page or provides shortcodes. I just need to add custom fields, and I need them to be able to write to columns in a datatable. So I’m looking for the correct hook so I can add whatever content I need to.

    As you saw in my topic (, I also wanted to do that.. My decision was to use custom fields provided by s2member and NOT to change the path they save data, but query them with regexp function (You can find some info here: or google it).. For my purposes I used something like this:
    mysql_query("SELECT * FROM wp_usermeta WHERE meta_key = 'wp_s2member_custom_fields' AND meta_value REGEXP '.*\"custom_data_name\";s:[0-9]+:\"custom_data_value\".*'");
    But you can use REGEXP wherever you want in your code to show data from serialized fields…

    Hmmm…I’ll look at it.

    Here is my data:

    meta_key	                                   meta_value
    wp_s2member_custom_fields	   a:2:{s:6:"reason";s:2:"ue";s:6:"county";s:1:"4";}

    Initially, I just had the “county” -> “4” part, and with help was able to use it. I’ve since added “reason” ->”ue”, but I’ve not been able to get the help I need to use that.

    Basically, I want to know what “reason” a person is subscribing. There are 11 options, “ue” being one of them.

    From there, if their reason is “hsbball” (one of the options), I then need to know what “county” they live in.

    Here is my whole query:

    $query = ‘SELECT um1.meta_value as custom, um2.meta_value as level, um3.meta_value as c_reason, u.ID, u.user_login, u.user_email
    FROM wp_usermeta um1
    INNER JOIN wp_usermeta um2
    INNER JOIN wp_usermeta um3
    ON um1.user_id = um2.user_id
    JOIN wp_users u
    ON um1.user_id = u.ID
    WHERE um1.meta_key = “wp_s2member_custom_fields”
    AND um2.meta_value LIKE “%s2member_level%”
    GROUP BY um1.user_id’;

    $result = mysql_query($query);

    //Process results into temp array
    $regionData = array();
    while($row = mysql_fetch_assoc($result))

    $custom = unserialize($row[‘custom’]);
    $user_region = $custom[‘county’];

    $level = unserialize($row[‘level’]);
    $level_desc = key($level); //E.g. s2member_level3

    // Trying to determine why someone is subscribing

    $reason = unserialize($row[‘c_reason’]);
    $user_reason = $reason[‘reason’];

    It doesn’t find any values for $user_reason, even though I should have two of them. The var_dump shows all the data when it’s uncommented.

    What if I have two custom data values in one of the fields? Does that work? (I can’t make heads or tails of REGEX samples I see on MySQL’s site.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding two fields to the Registration form…’ is closed to new replies.