The MU forums have moved to WordPress.org

Adding a field to registration? (31 posts)

  1. Sy4
    Member
    Posted 17 years ago #

    I need to add an additional field to the registration process.

    How easy is this to do, and can someone assist?

    Thanks
    matt

  2. modifiedcontent
    Member
    Posted 17 years ago #

    I asked basically the same question here.

    There are some plugins. I still haven't had time to try them. Hopefully later today.

    Any other suggestions are very welcome!

  3. Sy4
    Member
    Posted 17 years ago #

    I've lokoed at the registration and signup files, and think you just need to add a field and allow for this in the DB table.

    Going to test hopefully over the weekend. I just need to add one particular field, being contact number.

    As ModContent said, any help/input would be appreciated...Dr Mike? ;)

  4. modifiedcontent
    Member
    Posted 17 years ago #

    I have downloaded the WP-Members plugin. It has a long readme.htm file.

    It's hard to figure out what this plugin does exactly. It requires lots of edits to core code and is apparently more for access control than adding fields to the user table:

    The core of this plugin is that it keeps the membership tables separate from the wordpress users table. Additionally, the plugin uses its own cookie functions seperate from the WP user cookies.

    That's not what I want anyway. I want to add extra membership information to the existing user table in the database. Creating a second (?) cookie mechanism will probably only make it harder to integrate bbpress into my site.

    The readme.htm file says:

    There are already plugins that extend the existing WordPress users table to add user customizable fields like address info, etc.

    Where are these plugins?!

    usermeta and userextra also add their own new seperate table to the database, which just sounds like a bad idea.

    Adding fields to registration/user table seems like a pretty straightforward thing to do. Do you even need a plugin? Can't I just manually add fields to the user table and add some lines of generic php to the registration page?

  5. Sy4
    Member
    Posted 17 years ago #

    Modified,

    I was thinking exactly the same thing, except, I really suck at creating php and sql. I can only modify it.

    I'll set up a demo over the coming days and find out...Unless you've tried already?

    Thanks
    Matt

  6. modifiedcontent
    Member
    Posted 17 years ago #

    Sy4, I don't know php and sql either.

    I know how to insert fields into MySQL, but I don't know what attributes/settings to select and I'm clueless what code to put where in the php pages.

    Have you made any progress on your demo?

    I'm kinda stuck until someone can give us some pointers. If it's at all possible someone somewhere must have done this before.

    And where are those 'plugins that extend the existing WordPress users table to add user customizable fields like address info, etc.'?

  7. matrixmonkey
    Member
    Posted 17 years ago #

    what are you wanting to do?
    just ad an extra field? for use later
    or are you wanting it to give you diffrent results on what is put in the field

  8. modifiedcontent
    Member
    Posted 17 years ago #

    Just add extra fields for later use.

    I want to use registration for the site as registration for an association/club, so I would really like new members to fill out a form with address, phone number, field of business, resume, etc.

    The new fields shouldn't have to interfere with WPMU's regular functions. A lot of those fields will be optional, but I want to use the registration process to build a potentially usefull member database.

    This seems to me like a very common thing to do. Has nobody done it?

  9. modifiedcontent
    Member
    Posted 17 years ago #

    Here are several more threads about adding fields to registration and the user table in the database. All of them are dead ends:

    http://wordpress.org/support/topic/48399?replies=1
    http://wordpress.org/support/topic/58965?replies=1
    http://wordpress.org/support/topic/55434?replies=11
    http://wordpress.org/support/topic/72841?replies=2
    http://wordpress.org/support/topic/26895?replies=3

    fergbrain (Andrew Ferguson) is onto something here:

    http://www.andrewferguson.net/2006/05/16/add-data-to-user-field-in-wordpress/

    I haven't followed up on his suggestions yet. Not sure what the status of his solution is.

    Any new suggestions are very welcome!

  10. seblap
    Member
    Posted 17 years ago #

    You can add this thread to your list :

    http://wordpress.org/support/topic/63200

  11. drmike
    Member
    Posted 17 years ago #

    This plugin came over the wp-hackers mail list this morning. I don't know if it would help or not.

  12. SubnetZero
    Member
    Posted 17 years ago #

    It could. I could add a hook (and probably should) to the plugin allowing people to add fields to the form fairly easily.

  13. donncha
    Key Master
    Posted 17 years ago #

    Why not write a plugin that adds another profile page to the backend. That page would then add records to the usermeta table. You could easily have it display the page or a link to it whenever the user logs in untl they fill it in.

    Much better than adding fields to wp_users and much easier to upgrade in the future.

  14. SubnetZero
    Member
    Posted 17 years ago #

    Absolutely. I never modify core code (and you shouldn't either kids), and the only time I modify db tables is if I am intending on getting something into core code.

  15. mrjcleaver
    Member
    Posted 17 years ago #

    Well, whilst I agree never is optimal, I've started to collect a list of those that are frequently edited. See http://codex.wordpress.org/WPMU_Commonly_Edited_Core_Files

    Maybe together we can make this list empty, if we each take an item that we care about, and make it into a configuration item.

  16. kbf
    Member
    Posted 17 years ago #

    Guys, I like WP a lot... really, I'm a fan, and, I understand it's free software and for the people who make mods it's a labor of love, and, I'm very grateful...

    now, with that having been said, I'm honestly just pretty dumbfounded that a solid plug-in doesn't exist that would provide a nice gui to allow the admin to alter and add fields in the registration process....

    It seems like this is functionality that's by no means esoteric....... a lot of people could make use of this very fundamental feature.....

    I've been searching and reading for ten hours and finding little bits here and there, but, not the complete package.

    Thank you for the help,
    kf

  17. bigdadee
    Member
    Posted 17 years ago #

    I ran across this site today...check it out.

    http://www.flamingspork.com/projects/memberdb/

  18. drmike
    Member
    Posted 17 years ago #

    kbf, probably because no one has written it yet. Instead of complaining about the situation which does little but piss off folks around here, why don't you step up to the plate and solve the issue?

    That's a hint by the way. :)

  19. modifiedcontent
    Member
    Posted 17 years ago #

    kbf, probably because no one has written it yet. Instead of complaining about the situation which does little but piss off folks around here, why don't you step up to the plate and solve the issue?

    That's a hint by the way. :)

    We're not all php coders. That's why we try to use prefab php scripts. If we could code it ourselves, we would. Then no one would need WordPress.

    That's probably also the reason why no one writes this plugin or bothers to include it. For php coders adding fields to registration is probably a very easy modification.

    For the non-coders it stops projects dead in their tracks.

  20. modifiedcontent
    Member
    Posted 17 years ago #

    That memberdb looks interesting, but would it be hard to integrate in a WordPress MU site? Wouldn't it be easier to add fields to the existing member table and registration scripts?

    For the non-coders it still doesn't solve the problem...

  21. modifiedcontent
    Member
    Posted 17 years ago #

    This plugin came over the wp-hackers mail list this morning. I don't know if it would help or not.

    No damnit! A Themed Login Plugin is very cute but has nothing whatsoever to do with adding fields to the database.

    I don't know php, but I do know html and css. There are too many of these useless plugins that only add bells and whistles around the edges, but don't really do anything.

    I'm honestly just pretty dumbfounded that a solid plug-in doesn't exist that would provide a nice gui to allow the admin to alter and add fields in the registration process....

    It seems like this is functionality that's by no means esoteric....... a lot of people could make use of this very fundamental feature.....

    Totally agree. I gave up for a couple of months and there's still no solution. And all threads about this go off topic to things like themed logins and "trombinoscope features" (?!).

    So adding fields to the member table is impossible then?

  22. ryuuguu
    Member
    Posted 17 years ago #

    WEll I came here hoping to find a nice plugin tfor adding a field to the registration screen also. Nothing here so I wrote the beggining of one here
    http://www.ryuuguu.com/wordpress/2006/11/28/adding-extra-fields-to-wordpress-user-profiles/

    it is not a complete plugin because you have to edit code to set what want, but it is late and enough for me to use. I am not sure when/if I will have time to add a front end to let non-coders use it easily.

  23. PerS
    Member
    Posted 17 years ago #

    ryuuguu, nice. Just what I needed :)

  24. mrjcleaver
    Member
    Posted 16 years ago #

  25. WPITn2shape
    Member
    Posted 16 years ago #

    My comment's gone. Um I tested Cimy on MU and it works for the main blog only. I'm interested in understanding why.

    Here is a typical error:

    Warning: in_array() [function.in-array]: Wrong datatype for second argument in /wp-content/mu-plugins/Cimy_User_Extra_Fields/cimy_user_extra_fields.php on line 1930

  26. mrjcleaver
    Member
    Posted 16 years ago #

  27. el3nch
    Member
    Posted 16 years ago #

    If you would like to add fields without a plugin you can get away with the following, altho I consider myself an experienced devloper, I am definately NOT an experienced Wordpress developer (yet) so please do tell me if I am stepping outside the bounds of common sense here:

    This will add additional user fields to the usermeta table for Wordpress Mu (and I assume normal Wordpress aswell). I believe it's the latest version, but I wanted to check and post that when I can be specific on the version number I'm using so I will hazard a guess at it working on 2.3 and up.

    in /wp-admin/includes/user.php
    under the function edit_user()

    You will find some input definitions
    along the lines of

    if ( isset( $_POST['inputname'] ))
    $user->fieldname= wp_specialchars( trim( $_POST['inputname'] ));

    I tend to keep my field and input names the same to avoid confusion, here the input name will refer to the input in the form on the profile page. The fieldname will refer to the meta key in the meta table, make sure you don't use a metakey that is already in use either in wordpress or in another plugin etc or you may run into problems.

    Add as many of these as you need, one for each input and make sure that you add any logic here to control the input content such as caharacter replace etc, to avoid SQL injection methods as you are dealing with raw input data at this point.

    in /wp-includes/registration.php
    under the function wp_insert_user()

    You will find some variable definitions
    along the lines of

    if ( empty($variblename) )
    $variblename= '';
    $variblename= apply_filters('pre_user_variblename', $variblename);

    Now I don't profess to understand how this bit works, speficially the 'pre_user_'+ variblename part, the rest is pretty obvious, but I can say that if you replace all the variable names with the same fieldname you set in the section above you are half done.

    Next there is a part slightly lower in the same function that follows:

    update_usermeta( $user_id, 'metakey', $variablename);

    I make both the metakey and the variablename the same as the variablename used in the upper section of the function and I find that this then adds and updates a new meta key value pair for the fields that I want. The metakey is actually the meta_key stored in the table usermeta so be sure again not to use one that is already in use by something else.

    Hope that helps, if I have made a mistake or not clearly defined somethig then please let me know. I am not a frequent visitor to these forums but I will update my post with corrections should they be neccessary. Enjoy :)

  28. lunabyte
    Member
    Posted 16 years ago #

    Check out the do_action hooks, which allow for you to add additional fields to the profile page, as well as update those fields on post.

    Then you can tap into those with add_action, which saves a bunch of edits that have to be reproduced on every upgrade.

  29. Mattz
    Member
    Posted 16 years ago #

    Lunabyte,

    Do you have a good example for that ?

  30. lunabyte
    Member
    Posted 16 years ago #

    function my_function() {
      // html code for additional user form fields here
    }
    
    add_action('specific_profile_hook_here', 'my_function');

About this Topic