Custom Registration
-
Hi,
I want to customize my registration form (e.g. adding a required first name field as described here), but it seems that register_form and registration_errors are not compatible with WP MS.
I tried using signup_header instead of register_form as suggested here, but I ended up by the form elements added to the top of registration page instead of bottom of the registration form.
And, I tried using wpmu_validate_user_signup instead of registration_errors, but I ended up with a blank page instead of the error message after registration attempts.
Is there any way to use the normal registration page for WP MS? (My plugin works great with the normal WP, and I don’t want to allow the WP MS users to create blogs by themselves at registration.) Or, could you please tell me how I can customize the WP MS signup page?
Thanks,
Hooman
-
it goes in to a lot of the options.
I don’t want to allow the WP MS users to create blogs by themselves at registration.)
Well that’s by default.
/wp-admin/network/settings.php
Under “Allow new registrations” pick “User accounts may be registered.” or “Logged in users may register new sites.”
Thanks a lot for your quick response.
That page seemed really good, but I think it was more complicated and less flexible in comparison with WP single site signup page options.
And, about the settings, I’m using the exact same option; so I thought this less flexible WP MS signup page is useless for me, and I would prefer to have the normal registration page on my site.
Is there any way to totally replace this MS signup page with the normal signup page? (It can add the users to my network, and then I’ll assign them to blogs through my admin panel.)
That would be the normal signup page. /wp-admin/network/settings.php
Under “Allow new registrations” pick “User accounts may be registered.”
Thanks for your answer, but unfortunately, selecting “User accounts may be registered.” doesn’t make my WP MS signup page like the normal WP signup page for me.
The signup page is located at
/wp-login.php?action=registerin the normal WP installation and works great, but that page is located at/wp-signup.phpin my WP MS installation and doesn’t work with my plugin.How can I tell WP MS to use the
/wp-login.php?action=registerinstead of/wp-signup.php?You don’t.
You use wp-signup.php, and when you select “User accounts may be registered.” , that pages CHANGES to hide the blog sign up.
Dear Ipstenu,
It DOES “hide the blog sign up”, but it DOESN’T make
register_formand andregistration_errorswork! And, I want the normal WP signup page only to use those hooks!Do you think it is possible to change the WP MS signup process in a way that makes those hooks working again?
(I gave you the wrong options link in the beginning, my bad)
So register_form will (and should) still work. If it’s not, make sure the problem isnt your code.
I tried using signup_header instead of register_form as suggested here, but I ended up by the form elements added to the top of registration page instead of bottom of the registration form.
To go back to this… You may be hooking in thr wrong place. Can you share YOUR code? 🙂
Hi – I know what you mean, Hoom@n. I don’t quite have an answer but inching towards one.
Ipstenu, if I edit wp-signup.php, will WP updates overwrite it? Currently I’m customising with the idea that they will but if they don’t, then you can edit wp-signup.php without fear (I have the fear so am using a hodge-podge of jQuery and css).
if I edit wp-signup.php, will WP updates overwrite it?
Yes.
then you can edit wp-signup.php without fear
You really should be terrified. Honest. Don’t modify core WordPress files as it never ends well.
Can you please start your own topic and describe what you are attempting to accomplish?
Oh no! I am suitably terrified, believe me. I’ve been doing this on the assumption that updates can overwrite it, so have not touched it. I just wanted to triple check.
I’m trying to accomplish exactly what hoom@n is – customise my login page but I am having styling issues as well.
When you get to “Adding Users to Sites” you can stop, that part doesn’t matter. The first half about making a template, THAT is what you want to do.
Thank you so much, that is exactly what I was looking for – the whole post includes answers to questions I had but hadn’t asked here. I really really appreciate it, was banging my head against the wall – and there is so much bad information about wp-signup.php out there I had given up looking.
This is my code for a single site installation, which works well:
<?php /* Plugin Name: Custom Registration Description: This plugin customizes WordPress's built-in user registration page. Author: Hooman Tadbiri Version: 0.1 */ //1. Add a new form element... add_action('register_form','myplugin_register_form'); function myplugin_register_form (){ $first_name = ( isset( $_POST['first_name'] ) ) ? $_POST['first_name']: ''; $last_name = ( isset( $_POST['last_name'] ) ) ? $_POST['last_name']: ''; $validation_code = ( isset( $_POST['validation_code'] ) ) ? $_POST['validation_code']: ''; ?> <p> <label for="first_name"><?php _e('First Name','mydomain') ?><br /> <input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr(stripslashes($first_name)); ?>" size="25" /></label> </p> <p> <label for="last_name"><?php _e('Last Name','mydomain') ?><br /> <input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr(stripslashes($last_name)); ?>" size="25" /></label> </p> <p> <label for="validation_code"><?php _e('Validation Code','mydomain') ?><br /> <input type="text" name="validation_code" id="validation_code" class="input" value="<?php echo esc_attr(stripslashes($validation_code)); ?>" size="25" /></label> </p> <?php } //2. Add validation. In this case, we make sure first_name is required. add_filter('registration_errors', 'myplugin_registration_errors', 10, 3); function myplugin_registration_errors ($errors, $sanitized_user_login, $user_email) { if ( $_POST['user_login'] < 8000000000 || $_POST['user_login'] > 10000000000 ) $errors->add( 'user_login_error', __('<strong>ERROR</strong>: not valid username','mydomain') ); if ( empty( $_POST['first_name'] ) ) $errors->add( 'first_name_error', __('<strong>ERROR</strong>: You must include a first name.','mydomain') ); if ( empty( $_POST['last_name'] ) ) $errors->add( 'last_name_error', __('<strong>ERROR</strong>: You must include a last name.','mydomain') ); if ( $_POST['validation_code'] != $_POST['user_login'] ) $errors->add( 'validation_code_error', __('<strong>ERROR</strong>: not correct','mydomain') ); return $errors; } //3. Finally, save our extra registration user meta. add_action('user_register', 'myplugin_user_register'); function myplugin_user_register ($user_id) { if ( isset( $_POST['first_name'] ) ) update_user_meta($user_id, 'first_name', $_POST['first_name']); if ( isset( $_POST['last_name'] ) ) update_user_meta($user_id, 'last_name', $_POST['last_name']); } ?>(Usernames must be numeric, and users must enter a validation code which is their username for instance.)
And, this is my code for a multi-site installation, which doesn’t work:
<?php /* Plugin Name: Custom Registration Description: This plugin customizes WordPress's built-in user registration page. Author: Hooman Tadbiri Version: 0.1 */ //1. Add a new form element... add_action('signup_header','myplugin_register_form'); function myplugin_register_form (){ $first_name = ( isset( $_POST['first_name'] ) ) ? $_POST['first_name']: ''; $last_name = ( isset( $_POST['last_name'] ) ) ? $_POST['last_name']: ''; $validation_code = ( isset( $_POST['validation_code'] ) ) ? $_POST['validation_code']: ''; ?> <p> <label for="first_name"><?php _e('First Name','mydomain') ?><br /> <input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr(stripslashes($first_name)); ?>" size="25" /></label> </p> <p> <label for="last_name"><?php _e('Last Name','mydomain') ?><br /> <input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr(stripslashes($last_name)); ?>" size="25" /></label> </p> <p> <label for="validation_code"><?php _e('Validation Code','mydomain') ?><br /> <input type="text" name="validation_code" id="validation_code" class="input" value="<?php echo esc_attr(stripslashes($validation_code)); ?>" size="25" /></label> </p> <?php } //2. Add validation. In this case, we make sure first_name is required. add_filter('wpmu_validate_user_signup', 'myplugin_registration_errors', 10, 3); function myplugin_registration_errors ($errors, $sanitized_user_login, $user_email) { if ( $_POST['user_login'] < 8000000000 || $_POST['user_login'] > 10000000000 ) $errors->add( 'user_login_error', __('<strong>ERROR</strong>: not valid username','mydomain') ); if ( empty( $_POST['first_name'] ) ) $errors->add( 'first_name_error', __('<strong>ERROR</strong>: You must include a first name.','mydomain') ); if ( empty( $_POST['last_name'] ) ) $errors->add( 'last_name_error', __('<strong>ERROR</strong>: You must include a last name.','mydomain') ); if ( $_POST['validation_code'] != $_POST['user_login'] ) $errors->add( 'validation_code_error', __('<strong>ERROR</strong>: not 2','mydomain') ); return $errors; } //3. Finally, save our extra registration user meta. add_action('user_register', 'myplugin_user_register'); function myplugin_user_register ($user_id) { if ( isset( $_POST['first_name'] ) ) update_user_meta($user_id, 'first_name', $_POST['first_name']); if ( isset( $_POST['last_name'] ) ) update_user_meta($user_id, 'last_name', $_POST['last_name']); } ?>As a reminder, I don’t want to let my users create new blogs and I just need the “User accounts may be registered.”. The only thing I want more is to add first name, last name, and a validation field to the registration page.
Why not use
signup_extra_fields?I am looking into customizing the registration form for WP multisite. I can confirm that register_form and register_post are NOT called in WP multisite.
However signup_extra_fields is called
The topic ‘Custom Registration’ is closed to new replies.