WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Need to create custom registration fields and save data in my own database table

[Resolved] Need to create custom registration fields and save data in my own database table

  • Hello there! I’m using wordpress 3.4.1 and s2member plugin to hold a membership and register new users.

    Now I need to create custom registration fields (5-6 fields) and keep that data with an ID of user into my own table in database.

    I tried to create custom fields with s2member plugin, but it saves data to the wp_usermeta table under meta_key: “wp_s2member_custom_fields” as an array.

    Maybe there is a way to auto copy that data to my own table each time user signs up.. or maybe there is a plugin or a piece of php code to fill my needs? Maybe I need to create my own plugin?

    Please help, and thanks for your replies! =)

Viewing 14 replies - 1 through 14 (of 14 total)
  • I have to ask… why is the s2member plugin’s method of saving to an array not adequate? WordPress encourages plugin developers to use that method for saving data. I don’t entirely agree with that position but I do agree that there is no point in creating tables or inserting rows when you don’t have to. Plus, what you are proposing is going to duplicate data and you will have to put in some work to keep the two copies of that data synchronized. So, while I am happy to (try to) help I really do want to know what you are trying to accomplish first.

    s_ha_dum, thanks for reply!
    I have a facebook app that takes some custom data from ‘businesses’ table in my database.. Instead of adding this data manually after a user’s sign up, I want the user put his company data in those custom fields.. And his business data will automatically work in a facebook app..

    Ok. Like I said, you are going to have to worry about multiple copies of your user data, so will have to synchronize when the user registers and when the user is edited. That is going to be several different hooks– some or all of these ‘user_register’, ‘edit_user_profile’, ‘edit_user_profile_update’, ‘edit_user_{$field}’ and maybe more.

    You can see the available hooks here : http://adambrown.info/p/wp_hooks/version/3.4

    You don’t need to create a plugin necessarily but you willhave to hook functions into the right places.

    Thanks again!

    I don’t have a lot of experience in making hooks.. But i’ll try! Will these hooks work with my s2member array?

    These are WordPress core hooks. They should work with anything. These filters will let you run code when a user is created/edited. What you will then (probably) have to do is pull that array from the database, pull your values from the other table, synchronize them, and put them back.

    Hey there again!
    I’m sorry. I know, I’m annoying you..) but can you help me please in more details? I can’t figure out what exactly should I do, cause I know php not enough to do that. Please, HELP!

    I’m sorry but what you are asking is fairly complicated. I won’t be able to write a few lines of code and make this work. I will try to get you started tomorrow though.

    s_ha_dum
    What you think, maybe it would be easier to write a sql query for my app to have an access to the ID of the user and that s2member’s array of custom fields?

    It might be easier, though I don’t know that for sure. It still is not a trivial project but it would solve some issues, like having to keep two sets of data synchronized.

    I have 5 fields in my database table.. fb app connects to it through this code:

    mysql_query("SELECT * FROM mytable WHERE fbpageid = '".$page_id."'");
    probably i should replace is with this, right?

    mysql_query("SELECT user_id, wp_s2member_custom_fields FROM wp_usermeta WHERE meta_value.fbpageid = '".$page_id."'");

    But I don’t know, will my fb app recofnize the wp_s2member_custom_fields array…?

    Jeez….. the plugin authors couldn’t be bothered to use core WordPress functions?

    I don’t know the context of that code, so I can’t tell you if it is right or not.

    s2member is working on a version where their custom registration fields do write to their own data table columns, instead of arrays in the user_meta data table. I’m having the same issue as dix.alex and am looking for a solution.

    I think I can help dix.alex with his query if I can hook into the registration page. I just can’t seem to find where I would do that. Unless dix.alex has already found a solution. I hope so. 🙂

    Jim R Thanks, I’ve already found a solution for my problem.. Now I use regexp function within a query.. =)

    Talk to me. LOL
    Is regexp a plugin? I’m horrible with WP codex.

    On my main site, I use includes and bring a great deal of content to Pages in WP. I’d love to set up something similar on my registration page. (Not that that’s what you’re talking about.)

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘[Resolved] Need to create custom registration fields and save data in my own database table’ is closed to new replies.
Skip to toolbar