Last week I released version 1.5 of my Simplr Registration Forms plugin. The new version includes some big fixes and requested features. Particularly, this version now supports WP Multisite and has a few addition profile fields that can be added to the default form. It also includes better security, via WP nonces, and better field validation.
But the most important change is that it includes hooks and filters that allow it to be extended by you, the user.
For instance, let’s add a field to our form that requests the user’s zip code. First, in your functions.php file create a function for displaying the field:
function sample_zip_field($form) {
$form .= '<div>';
$form .= '<label for="zip">Zip Code:</label>';
$form .= '<input type="text" name="zip" value="'.$_POST['zip'] .'"/><br/>';
$form .= '</div>';
return $form;
}
Note that this function receives the parameter $form and then returns $form. Failing to return the form will make the entire registration form disappear. To add this form to the registration use:
add_filter('simplr_add_form_fields', 'sample_zip_field');
But then we also need to make sure this data gets saved when the for gets saved. So you’ll need to create a function for that as well.
function sample_save_meta($user_id) {
if(isset($_POST['zip'])) {
add_user_meta($user_id, 'user_zip', $_POST['zip']);
}
return $user_id;
}
Note that in order for this function to work properly it has to receive the $user_id. It is also good practice to return the $user_id at the end of the function, though not necessary.
To make sure your save function is called use the hook:
add_action('simplr_profile_save_meta','sample_save_meta');
With these two “hooks”, you can customize the registration form however you want. You could even set up your field function to only display on certain pages, making it form-specific.
Finally, I’ve also added filters to the labels on the default form fields so you can change them at will. For instance, to change username to “screen name” use the following.
function sample_label_username($label) {
$label = "Screen name: ";
return $label;
}
add_filter('simplr_label_username','sample_label_username');
I hope you find the changes useful.
Mike, thank you for your post. I have a question, following you description for this plug in users, can register as a teacher or student, etc. I wanted to know if there was a way, or some suggestions in having different registration inquiries based on the user specific role (Teacher/Student)
Thanks!
Hey there. Does this version support creating a password field so users are able to create their own password instead of a random generated?
No, version 1.6 will have that option. It should be available in couple weeks.
Hi Mike,
Thanks for your great plugin. How I can put the registration form from other website?
I have a landing page that doing well in search engine. This landing page are from other website. I want to put the registration form at this landing page.
Hi
Is it possible to make the custom fields required fields when registering?
Thanks
Hi, thanks for making this plugin. However, I am very new to PHP etc. and much of this went over my head. Do you have any plans on adding a settings panel?
How about that first question:
“I wanted to know if there was a way, or some suggestions in having different registration inquiries based on the user specific role?”
Can we do this?
Thanks in advance for any info,
R
Hi, this is a great Plugin and explanation. I would use it but I need also a “Edit Profile page”. I thinks that would complete your software for its purposes of having a front end for the users.
Do you have any tips about that?
Or can you make a job quotation for this need? I would hire you if you are available.
Thanks, david
;Hey mike,
Is there any way i can group my fields ?
General
Usernmae Passwword
Other Information
Addresss Zip PostCode
Extra Information
Hobbies Fav team
I’m working on field groupings for Version 2.2
Sweeeet
FYI, still working on this. I’m hoping to have it ready in May.
Hi, great plugin, but when I went to add a custom field to the form (a telephone number field) following your instructions above in the functions.php file, the form is no longer output to the browser. All I have is the custom telephone number field I created along with the submit button.
Also, as Nicole asked above, can we make the fields required?
Found the culprit.
On line 413 of the simplr_reg_page.php you have this:
[code]$form = apply_filters('simplr_add_form_fields', $form);[/code]
it should be this:
[code]$form .= apply_filters('simplr_add_form_fields', $form);[/code]
Hmmm, that shouldn’t matter, just make sure to $form .= WHATEVER in your filter and you should be fine.
it does matter, because when you are outputting the form in the main file, when it gets to that line code it does not append the filter options to the value of the already existing form variable, but rather sets the value of the form variable to only the filter options.
But since the whole of the form var is being passed to the filter the whole form variable will be passed back … IF you have appended in the filtering function. It’s six of one, half dozen of the other isn’t it???
true, but all I know is that it does not work without it.
Can you post the function exactly as you’ve written it? Or email it to me?
sure
function user_phone_num_field($from) {
$form .= ”;
$form .= ‘Phone Number: *’;
$form .= ”;
$form .= ”;
return $form;
}
function save_user_phone_num($user_id) {
if(isset($_POST['tel'])) {
add_user_meta($user_id, ‘user_phone_num’, $_POST['tel']);
}
return $user_id;
}
add_filter(‘simplr_add_form_fields’, ‘user_phone_num_field’);
add_action(‘simplr_profile_save_meta’,'save_user_phone_num’);
it stripped out the html for the tags, but you get the idea
Joe, change
user_phone_num_field($from)touser_phone_num_field($form)and let me know if that helps.wow… my bad… that does work great.
I may have fat finger syndrome…
Hey no worries. I do that all the time. I’m just glad it’s working for you.