Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* The code below is a combination of code snippets provided by:
- // Eric Martin, the creator of the SimpleModal Login plugin http://wordpress.org/extend/plugins/simplemodal-login/
- // and Slobodan Manic https://gist.github.com/slobodan
- // Tested, verified to work for me - Your mileage may vary.
- */
- add_filter('simplemodal_registration_form', 'mytheme_registration_form');
- function mytheme_registration_form($form) {
- $options = get_option('simplemodal_login_options');
- $output = sprintf('
- <form name="registerform" id="registerform" action="%s" method="post">
- <div class="title">%s</div>
- <div class="simplemodal-login-fields">
- <p>
- <label>%s<br />
- <input type="text" name="user_login" class="user_login input" value="" size="20" tabindex="10" /></label>
- </p>
- <p>
- <label for="password">%s<br/>
- <input id="password" class="user_pass input" type="password" tabindex="15" size="25" value="" name="password" />
- </label>
- </p>
- <p>
- <label for="repeat_password">%s<br/>
- <input id="repeat_password" class="user_pass input" type="password" tabindex="30" size="25" value="" name="repeat_password" />
- </label>
- </p>
- <p>
- <label>%s<br />
- <input type="text" name="user_email" class="user_email input" value="" size="25" tabindex="35" /></label>
- </p>',
- site_url('wp-login.php?action=register', 'login_post'),
- __('Register', 'simplemodal-login'),
- __('Username', 'simplemodal-login'),
- __('Password', 'simplemodal-login'),
- __('Repeat Password', 'simplemodal-login'),
- __('E-mail', 'simplemodal-login')
- );
- ob_start();
- do_action('register_form');
- $output .= ob_get_clean();
- $output .= sprintf('
- <p class="reg_passmail">%s</p>
- <p class="submit">
- <input type="submit" name="wp-submit" value="%s" tabindex="100" />
- <input type="button" class="simplemodal-close" value="%s" tabindex="101" />
- </p>
- <p class="nav">
- <a class="simplemodal-login" href="%s">%s</a>',
- __('A password will be e-mailed to you.', 'simplemodal-login'),
- __('Register', 'simplemodal-login'),
- __('Cancel', 'simplemodal-login'),
- site_url('wp-login.php', 'login'),
- __('Log in', 'simplemodal-login')
- );
- if ($options['reset']) {
- $output .= sprintf(' | <a class="simplemodal-forgotpw" href="%s" title="%s">%s</a>',
- site_url('wp-login.php?action=lostpassword', 'login'),
- __('Password Lost and Found', 'simplemodal-login'),
- __('Lost your password?', 'simplemodal-login')
- );
- }
- $output .= '
- </p>
- </div>
- <div class="simplemodal-login-activity" style="display:none;"></div>
- </form>';
- return $output;
- }
- // Add password fields for submit
- add_action( 'user_register', 'ts_register_extra_fields', 100 );
- function ts_register_extra_fields( $user_id ){
- $userdata = array();
- $userdata['ID'] = $user_id;
- if ( $_POST['password'] !== '' ) {
- $userdata['user_pass'] = $_POST['password'];
- }
- $new_user_id = wp_update_user( $userdata );
- }
- // Check password match and length requirement
- add_action( 'register_post', 'ts_check_extra_register_fields', 10, 3 );
- function ts_check_extra_register_fields($login, $email, $errors) {
- if ( $_POST['password'] !== $_POST['repeat_password'] ) {
- $errors->add( 'passwords_not_matched', "<strong>ERROR</strong>: Passwords must match" );
- }
- if ( strlen( $_POST['password'] ) < 6 ) {
- $errors->add( 'password_too_short', "<strong>ERROR</strong>: Passwords must be at least eight characters long" );
- }
- }
- // Change password e-mail text
- add_filter( 'gettext', 'ts_edit_password_email_text' );
- function ts_edit_password_email_text ( $text ) {
- if ( $text == 'A password will be e-mailed to you.' ) {
- $text = 'Password must be at least six characters long.';
- }
- return $text;
- }
- // Change sucess email text
- add_filter( 'gettext', 'ts_edit_login_email_text' );
- function ts_edit_login_email_text ( $text ) {
- if ( $text == 'Registration complete. Please check your e-mail.' ) { $text = 'Registration complete, please log in.';
- }
- return $text;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement