Force User Field Registration
NOTE: Force User Field Registration will be going End-of-Life soon. WordPress 2.6.x will be the last supported version! Read more: http://andrewferguson.net/2008/08/06/force-user-field-registration-end-of-life/
Overview
Forces new users to register additional fields. Available fields are:
- First Name
- Last Name
- Nickname
- AIM screen name
- Yahoo IM screen name
- Jabber/Google Talk user name

Compatibility
- 2.5.*
Warning: This plugin WILL NOT work with version prior to 2.5!
Installation for Regular WordPress
Download the file and put it in your plugins directory.
Activate it.
To configure what fields are required register an account, login to the WordPress Dashboard. Then go to “Options” > “Force User Field Registration”
Known issues:
- There are no known issues.
Installation for WordPress MultiUser
Download the file and put it in your plugins directory.
Activate it.
To configure what fields are required register an account, login to the WordPress Dashboard. Then go to “Options” > “Force User Field Registration”
Known issues:
- There are no known issues with the MU version.
Download
Latest version:
Change Log
0.6
Release Date: 5/19/2008
* Added PHPDoc
* Updated add_action to use inbuilt filter rather then have users add their own
* Update admin UI to 2.5 LnF
* Updated input tag to make it look like native input tags
* Updated fergcorp_forceRegistrationField_updateFields to use passed variable instead of DB query
* Updated error handling in fergcorp_forceRegistrationField_checkFields to use the new WP_Error object (note: this makes WP 2.5 a minimum requirement)
0.6 MU
Release Date: 1/17/2008
Only worked with username-only signups. Now it works with all types of signups.
0.5 MU
Release Date: 1/15/2008
Port of standard WP version to the WPMU platform to accommodate the architecture differences.
Changes include:
Some add_actions were changed to add_filters to take advantage of MU specific filter hooks.
Added a new function to accommodate the differences in WPMU user registration.
Enjoy!
0.5
Release Date: 10/27/2007
Added back end management. This should make it pretty easy to use.
Updated code to take advantage of already established WordPress functions
Removed URL option due to a move in the WP database.
0.11
Release Date: 9/19/2007
Fixed hardcoded database entry and updated homepage link
Hosting switched to separate entity (i.e. no longer under fergcorp directory on svn)
0.1
Release Date: Long time ago
Original release
RSS
Perhaps you could add support (or integrate something similar) to
http://dev.wp-plugins.org/wiki/Userextra ?
Great plugin, Andrew, thank you so very much.
I’m messing around with the code trying to get First Name / Last Name / whatever fields I include to show up above Username / Email Address but not getting very far.
Any clue how I might go about this?
Any help is greatly appreciated. 8}
The additional fields are added using a WordPress hook. This hook occurs after the username and email address fields.
In order to put fields in front of the username/email fields, you’ll have to physically modify the
wp-login.phppage. These modifications are outside the scope of this plugin, but shouldn’t be too hard to figure out.Thanks for the reply, Andrew.
I decided to take the easy route and just use CSS to move them around, but I’ll look into messing with the hooks.
I’ve used this plugin in combination with the one I found here http://www.cimatti.it/blog/2007/02/12/cimy-user-extra-fields-for-wordpress-21/
to make a pretty detailed registration page. (temp URL, but if you’re interested: http://dev.proteabio.com/wp-login.php?action=register )
Much appreciated!
Glad it all works.
A general note to all:
I just added a donation button on the side bar (up and the right), so if you *really* like my plugins (and/or me) you might consider making a donation. I’m a college student (3rd year Elect. Eng.) and really only do this programming thing on the side for the love of it.
This plugin works as advertised. I’m very happy with it. Although, this is something that I wish the WP dev team had figured out a long time ago. Thanks for picking up the slack. This will improve the CRM features of my blogs a great deal.
Awesome! Exactly what I was looking for.
this problem is coming when i paste ur code on line 245
Parse error: syntax error, unexpected T_VARIABLE in E:\suresh\xampplite\htdocs\wordpress\wp-login.php on line 242
plz help
Hey, great and neat plug in. I do have a question:
If I want to add a check box for privacy policy and not let the user register without checking it, will it be possible to add it to your script? and if it is yes, what will be the recommended approach for that?
Thanks
Mor
Yeah, thats what i was searching for. I use this for an article directory with many many authors.
If someone is interested in an email-notification plugin for WP just contact me. it notify the admin if a new draft is saved and it notify the users if an article is published by the admin.
Maybe i will make it publish it one time
Andrew,
The plugin is working as far as adding the extra fields… but it is not populating them into the users profile. The only extra fields that I am requiring are First and Last Name. But they are not being added to the Profile.
Any suggestions?
After some more digging, I have found this:
http://wordpress.org/support/topic/109150
He has the same exact issue that I have.
Help?
Fix: in function fergcorp_forceRegistrationField_updateFields, instead of INSERT INTO `kpipress_usermeta` use this:
INSERT INTO $wpdb->usermeta
Why not make the $optionsValue variable global, or put it in one function?
It would be nice if the Wordpress team added a call to apply_filter in wp_login.php so that we do not have to edit that file each time we’re upgrading wordpress.
aloha!
Lawrence
Nice plugin, but Im confused as to where I change the actual fields? Is there an interface?
Jake
@Jake Rutter:
There is no interface yet (adding one is on a growing list of things to do). To change the fields, you’ll need to edit the plugin itself.
Great plugin, Andrew. I added some code at the bottom of the function fergcorp_forceRegistrationField_updateFields() so that the display name would be set to firstname lastname. If/when you get around to creating a user interface, you might consider allowing folks to set the default display name.
[php]
/* sets display name to first name, last name*/
$ln=$_POST['last_name'];$fn=$_POST['first_name'];$dn=$fn.” “.$ln;
$query = “UPDATE $wpdb->users SET display_name = ‘$dn’ WHERE ID = ‘$user_id’”;
$query = apply_filters(’update_user_query’, $query);
$wpdb->query( $query );
[/php]
Hi Andrew,
I want to use your plugin with WP 2.2.2 but I alway get this error message, if I want to register a new user on my blog:
WordPress database error: [Table 'XXXXXXX.wp_usermeta' doesn't exist]
INSERT INTO `wp_usermeta` ( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES (NULL , ‘19′, ‘first_name’, ‘Hermann’)
WordPress database error: [Table 'XXXXXXX.wp_usermeta' doesn't exist]
INSERT INTO `wp_usermeta` ( `umeta_id` , `user_id` , `meta_key` , `meta_value` ) VALUES (NULL , ‘19′, ‘last_name’, ‘Dobler’)
Warning: Cannot modify header information - headers already sent by (output started at XXXXXXX/wp-includes/wp-db.php:133) in XXXXXXX/wp-includes/pluggable.php on line 341
Do you have any solution for this problem?
@Alfons:
I had hard coded one of the databases when it should have been dynamic. Download the latest version (v0.11) and that should solve your problem:
http://downloads.wordpress.org/plugin/force-registration-field.zip
Thank you very much for your quick fix! It works fine.
Just a small improvement: It would be useful to change the tapindex to 30. Otherwise the order is messy if you use the tap-key.
Would it be possible to set with your plugin also the name which is used on the blog. Would be ok to have it automatic. I guess at the moment the nickname are used as default.
I’ve already modified my wp-login.php file, so my line 245 isn’t the default. Can you tell me what code should be infront and following your inserted do_action?
Thanks!
Hopefully this helps:
[php]
else {
do_action(’fergcorp_forceRegistrationField_hook’); //Add this line
wp_new_user_notification($user_id, $user_pass);
wp_redirect(’wp-login.php?checkemail=registered’);
exit();
}
[/php]
@Alfons:
It would be useful to change the tapindex to 30
Yea, I saw that when I was upgrading it. I’ll make a note of that for the next release.
Would it be possible to set with your plugin also the name which is used on the blog. Would be ok to have it automatic. I guess at the moment the nickname are used as default.
I’ll look into this as another option.
Hello I finally got the Plug in to work as far as showing up and forcing people to register. But when they register there is an error and it does not email the password. Word press 2.2 and plug in V. 0.11 did I do something wrong or is it that the email is not setup in the wp-login ?
Here is a copy of the error I received.
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, support@supportwebsite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/1.3.33 Server at power4deliverance.org Port 80
@PastorP:
I haven’t run into this error with the plugin. My guess is that something isn’t setup right.
Some things I’d check:
If you disable the plugin, are you able to register normally?
Did you remember to add
do_action('fergcorp_forceRegistrationField_hook');to the appropriate place in the wp-login.php file?here is the errors log from the server
[Sun Sep 23 22:53:32 2007] [error] [client 209.249.86.17] File does not exist: /var/chroot/home/content/b/e/t/bethyah/html/robots.txt
[Mon Sep 24 00:09:33 2007] [error] [client 59.93.25.231] File does not exist: /var/chroot/home/content/b/e/t/bethyah/html/Assets/assets/seattle_background_paint.jpg
[Mon Sep 24 02:17:31 2007] [error] [client 38.99.44.102] File does not exist: /var/chroot/home/content/b/e/t/bethyah/html/robots.txt
convert: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory
convert: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory
[Mon Sep 24 04:13:08 2007] [error] [client 76.160.223.161] malformed header from script. Bad header= \x01@\x01>P: /var/chroot/home/content/b/e/t/bethyah/html/advancedguestbook/addentry.php
[Mon Sep 24 04:34:38 2007] [error] [client 76.160.223.161] malformed header from script. Bad header= \x01@\x01>P: /var/chroot/home/content/b/e/t/bethyah/html/wordpress/wp-login.php
@PastorP:
Based on your error logs, there’s something wrong with wp-login.php.
[Mon Sep 24 04:34:38 2007] [error] [client 76.160.223.161] malformed header from script. Bad header= \x01@\x01>P: /var/chroot/home/content/b/e/t/bethyah/html/wordpress/wp-login.php)…unfortunately, there are several things it could be and without seeing the actual code, I can’t make any guesses.
You’re welcome to email me your wp-login.php page and I’ll take a look at it.
Hello, there is a little error on file.
On Wordpress 2.3 if I install the plugin there is an error on line 84.
Replace <? in <?php on line 53.
Bye
Hi Andrew,
since I’m using your plugin I always get this error message if I want to delete a member:
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘Array’ was given in /is/htdocs/XXXXXX/wp-includes/plugin.php on line 160
Warning: Cannot modify header information - headers already sent by (output started at /is/htdocs/XXXXXXXX/wp-includes/plugin.php:160) in /is/htdocs/XXXXXX/wp-includes/pluggable.php on line 341
Afterwards the member is deleted, but something should be wrong. Do you have any advise?
@Alfons:
What version of WordPress are you using? Can you please give step-by-step instructions to reproduce the problem (i.e. what exactly did you do)?
@Michele Facchin:
Good catch. Thanks! Although, I don’t know if it’s an error…it’s at least considered bad programming practice.
I’m using WP 2.2.2
I go to http://www.XXX.com/wp-admin/users.php then check a checkbox of a user then I go down to check “Delete user” and click to “send”
Afterwards a white page with this error message appear.
Hi Andrew,
Love your Plugin. It works great with a small footprint. Can you give me any clues to adding a dropdown select list using this plug?
Thanks,
Ryan
@Ryan:
Are talking about a drop down list on the actual registration page or in the management section?
Just to add Andrew,
I am using Wordpress v2.3 and I have your latest plugin v0.5
I am wanting to add a select age field to the registration page? I used your php script to add an age text input field and it worked great. Now I am trying to make the age input a dropdown select field.
Thanks, Ryan
OK, so I upgraded to version .5 of this fine plugin and also upgraded to version 2.3.1 of WordPress. Now my new wp-login.php file, of course, does NOT contain the hook code specified above. BUT, the registration plugin works anyway?
Does version .5 no longer require one to add the specified code to wp-login.php?
Nevermind, my browser was caching an old copy of wp-login.php. Sorry for the stupidity!
@camner:
No worries.
I really do want to make it so that there is not file modification that needs to be done because it can be a PITA to have to modify that file every single time you upgrade.
Great stuff. But how do I see the values entered by the users in the admin area? I can’t see them in the Users table or in the more detailed Edit User view either.
@mikko:
Did you edit the wp-login.php file to include
do_action('fergcorp_forceRegistrationField_hook');?Also, what version of WordPress and Force User Field Registration are you using?
Yes, I did (line 253 in the case of 2.3.1.). Versions 2.3.1 and 0.5 respectively. Does it make a difference I have users in the table from before installing the plugin?
@Ryan:
You’ll want to modify line 94. Let me know if you need more help.
@mikko:
It does not make a difference if you already have users. This plugin does not add any new columns to tables. The data is actually stored separate from the users data and is linked to it via
user_id. What extra data are you trying to collect? Do you have any other plugins that modify users or user registration? I’m attempting to replicate the issue on my end.I’m trying to collect just a nickname, and a short reply to a short question. So these added fields should be visible in the Users tab in the Admin view?
I have Bouncer 0.82 (php4 version), User Permissions 0.6 and Role Manager 1.4.5 activated - not sure if these can have an effect?
@mikko & @Ryan:
Oh, ok. I think there’s some misunderstanding here. Force User Field Registration is designed to force users to register fields that WordPress has already designated. If you look at the overview section, there are six fields that you can force registration of. These are the only six fields that designed to be registered.
I can definitely see how there was confusion. I have some old code for adding additional meta fields that I might release at some point. This old code in conjunction with Force User Field Registration would probably fulfill your needs, mikko.
Hi Andrew,
I was able to get my registration “age” drop down select field working.
I added [php]“age” => “Age:”[/php] to the knownFields array and modified the input to this:
<select id=”" name=”" value=”" class=”input” size=”1″>
Select
18-24
25-34
35-54
55+
I doubt I did this correctly, but the values post with the other user meta and all seems to work good.
I added this field to user_edit.php:
[php]
<input type=”text” name=”age” value=”age ?>” />[/php]
and it works to display the value in the admin user edit page.
Thanks,
Ryan
Sorry, Having issues entering the code.
Modified Input:
[html]
<select id=”" name=”" value=”" class=”input” size=”1″>
Select
18-24
25-34
35-54
55+
[/html]
User_edit.php added:
[html]
<input type=”text” name=”age” value=”age ?>” />[/html]
Alright, thanks Andrew and Ryan too. Will try Ryan’s fix to begin with, but seeing your old code Andrew would of course be great!
@mikko:
Okay. I’ve dug out the code, dusted off the cobwebs, and have requested a spot on the dev server (usually takes about a week or so to get space allocated).
In the meantime, I’m updating the code to A) hide all the hideous code I wrote, and B) take advantage of some of the new or previously-unknown-to-me functions that WordPress has.
Mostly as an FYI, but the next three weeks will see me take a trip to hell and back (hopefully back) as I have three rather hard exams to contend with. In short, if I disappear for a few days…you know where I’ve gone.
@Ryan, et al:
FYI: You don’t need to escape the code you put in comments. That is, you can use < and not <
Hi. Plugin is great! I’m using it as a gateway for my modified wordpress CMS project. But I too am having the same problems as Alfons re: deleting a member and seeing this:
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘Array’ was given in /wp-includes/plugin.php on line 164Warning: Cannot modify header information - headers already sent by (output started at /home/theoblat/public_html/wp-includes/plugin.php:164) in /wp-includes/pluggable.php on line 391Deletion still works but still the warnings are there.
On a side note, I was wondering how could I hack the plugin so that after I send the approval e-mail, it automatically changes the display name to the First Name + Last Name of the user?
Hello!
I am not sure what to do in my case. Here are my lines 237 to 254. How should it look after the change? What do I have to replace, what has to be how it is?
if ( $user_login && $user_pass && empty( $errors ) ) {
$user = new WP_User(0, $user_login);
// If the user can’t edit posts, send them to their profile.
if ( !$user->has_cap(’edit_posts’) && ( empty( $redirect_to ) || $redirect_to == ‘wp-admin/’ ) )
$redirect_to = get_option(’siteurl’) . ‘/wp-admin/profile.php’;
if ( wp_login($user_login, $user_pass, $using_cookie) ) {
if ( !$using_cookie )
wp_setcookie($user_login, $user_pass, false, ”, ”, $rememberme);
do_action(’wp_login’, $user_login);
wp_safe_redirect($redirect_to);
exit();
} else {
if ( $using_cookie )
$errors['expiredsession'] = __(’Your session has expired.’);
}
}
@Lars:
What version of WordPress are you using? The lines you quoted above seem to be lines 318 to 335 of Wordpress v2.3.2 which is not the correctly place.
I am using WP Multiuser, my wp-login.php just has 316 lines.
Hope you can help!
@Lars:
First, I haven’t done any testing with this plugin and WP-MU, so it may not even work. But you’ll want to modify lines 124-129 to make it look like:
if (FALSE == wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_option('blogname')), $message)) { die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>'); } else { do_action('fergcorp_forceRegistrationField_hook'); wp_redirect('wp-login.php?checkemail=confirm'); exit(); }Note the addition of the ‘do_action’ line right before the ‘wp_redirect’ line.
Hi,
This looks like a perfect plugin but as far as I can see, it does not work on the MU version as you described.
@Mattz:
This plugin was never designed for WPMU nor have I done any testing with it for WPMU.
Hi Andrew,
thank you for your support, I did the changes but nothing happens.
Maybe anybody find a solution for that because I like the plugin.
@Lars:
School has started back up, so my free time pretty much has shot down to zilch, but I’ll try to poke around and see what I can figure out.
Thanks for your support, good luck in school!
@Lars & Mattz, et al:
Hey, so guess what. I made a version just for you guys (and anyone else using WPMU): Force User Field Registration for WMPU v0.5
I’ve done some preliminary testing and everything seems to be working okay. GIve it a shot and let me know what you think.
Hi Andrew,
I was searching again and found this update today, really great ! I’m very happy with this, thanks !
Would it be possible now too, to add you own userfields that you can add to the plugin, have you tested something like that ?
Thanks again, really great !
Hi Andrew,
In some strange way I’m forces back to the first page of registration and the additional fields like, Name and Surename, are red and I need to fill them in again.
I have to check if it’s my wp-signup.php that is messed up, but I thought, I will let you know
@Mattz:
Hmm, that’s interesting. I reproduced the error on my end, so it’s not your anything you did.
It only seems to happen when a new user also wants to register a new blog. I’ll take another gander through the code and see what I can figure out.
Hi Andrew,
OK, nice to hear, thanks.
Do you have an idea to add extra fields to the user that can be filled in this way too ?
This would be awesome too.
@Mattz, et al:
I’ve uploaded version 0.6 for MU which fixes the user registration bug. I’ll continue to work on implementing admin customizable user fields in my free time (maybe this weekend?)
Hey Andrew,
Wow, that is great, I will test it asap (today).
We keep in touch, you know where to reach me !
Thanks again !