Changeset 706727
- Timestamp:
- 05/02/2013 02:13:15 AM (13 years ago)
- File:
-
- 1 edited
-
register-plus-redux/trunk/rpr-signup.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
register-plus-redux/trunk/rpr-signup.php
r706285 r706727 400 400 <?php 401 401 } 402 }403 404 public /*.void.*/ function rpr_signup_hidden_fields() {405 global $register_plus_redux;406 if ( '1' === $register_plus_redux->rpr_get_option( 'double_check_email' ) ) {407 $user_email2 = isset( $_REQUEST['user_email2'] ) ? (string) $_REQUEST['user_email2'] : '';408 echo "\n", '<input type="hidden" name="user_email2" value="', esc_attr($user_email2), '" />';409 }410 if ( is_array( $register_plus_redux->rpr_get_option( 'show_fields' ) ) && in_array( 'first_name', $register_plus_redux->rpr_get_option( 'show_fields' ) ) ) {411 $first_name = isset( $_REQUEST['first_name'] ) ? (string) $_REQUEST['first_name'] : '';412 echo "\n", '<input type="hidden" name="first_name" value="', esc_attr($first_name), '" />';413 }414 if ( is_array( $register_plus_redux->rpr_get_option( 'show_fields' ) ) && in_array( 'last_name', $register_plus_redux->rpr_get_option( 'show_fields' ) ) ) {415 $last_name = isset( $_REQUEST['last_name'] ) ? (string) $_REQUEST['last_name'] : '';416 echo "\n", '<input type="hidden" name="last_name" value="', esc_attr($last_name), '" />';417 }418 if ( is_array( $register_plus_redux->rpr_get_option( 'show_fields' ) ) && in_array( 'user_url', $register_plus_redux->rpr_get_option( 'show_fields' ) ) ) {419 $user_url = isset( $_REQUEST['user_url'] ) ? (string) $_REQUEST['user_url'] : '';420 echo "\n", '<input type="hidden" name="user_url" value="', esc_attr($user_url), '" />';421 }422 if ( is_array( $register_plus_redux->rpr_get_option( 'show_fields' ) ) && in_array( 'aim', $register_plus_redux->rpr_get_option( 'show_fields' ) ) ) {423 $aim = isset( $_REQUEST['aim'] ) ? (string) $_REQUEST['aim'] : '';424 echo "\n", '<input type="hidden" name="aim" value="', esc_attr($aim), '" />';425 }426 if ( is_array( $register_plus_redux->rpr_get_option( 'show_fields' ) ) && in_array( 'yahoo', $register_plus_redux->rpr_get_option( 'show_fields' ) ) ) {427 $yahoo = isset( $_REQUEST['yahoo'] ) ? (string) $_REQUEST['yahoo'] : '';428 echo "\n", '<input type="hidden" name="yahoo" value="', esc_attr($yahoo), '" />';429 }430 if ( is_array( $register_plus_redux->rpr_get_option( 'show_fields' ) ) && in_array( 'jabber', $register_plus_redux->rpr_get_option( 'show_fields' ) ) ) {431 $jabber = isset( $_REQUEST['jabber'] ) ? (string) $_REQUEST['jabber'] : '';432 echo "\n", '<input type="hidden" name="jabber" value="', esc_attr($jabber), '" />';433 }434 if ( is_array( $register_plus_redux->rpr_get_option( 'show_fields' ) ) && in_array( 'about', $register_plus_redux->rpr_get_option( 'show_fields' ) ) ) {435 $description = isset( $_REQUEST['description'] ) ? (string) $_REQUEST['description'] : '';436 echo "\n", '<input type="hidden" name="description" value="', esc_attr($description), '" />';437 }438 439 $redux_usermeta = get_option( 'register_plus_redux_usermeta-rv2' );440 if ( is_array( $redux_usermeta ) ) {441 foreach ( $redux_usermeta as $meta_field ) {442 if ( !empty( $meta_field['show_on_registration'] ) ) {443 $meta_key = esc_attr( $meta_field['meta_key'] );444 $meta_value = isset( $_REQUEST[$meta_key] ) ? (string) $_REQUEST[$meta_key] : '';445 echo "\n", '<input type="hidden" name="', $meta_key, '" value="', esc_attr($meta_value), '" />';446 }447 }448 }449 450 if ( '1' === $register_plus_redux->rpr_get_option( 'user_set_password' ) ) {451 $pass1 = isset( $_REQUEST['pass1'] ) ? (string) $_REQUEST['pass1'] : '';452 echo "\n", '<input type="hidden" name="pass1" value="', esc_attr($pass1), '" />';453 $pass2 = isset( $_REQUEST['pass2'] ) ? (string) $_REQUEST['pass2'] : '';454 echo "\n", '<input type="hidden" name="pass2" value="', esc_attr($pass2), '" />';455 }456 if ( '1' === $register_plus_redux->rpr_get_option( 'enable_invitation_code' ) ) {457 $invitation_code = isset( $_REQUEST['invitation_code'] ) ? (string) $_REQUEST['invitation_code'] : '';458 echo "\n", '<input type="hidden" name="invitation_code" value="', esc_attr($invitation_code), '" />';459 }460 if ( '1' === $register_plus_redux->rpr_get_option( 'show_disclaimer' ) ) {461 $accept_disclaimer = isset( $_REQUEST['accept_disclaimer'] ) ? '1' : '0';462 echo "\n", '<input type="hidden" name="accept_disclaimer" value="', esc_attr($accept_disclaimer), '" />';463 }464 if ( '1' === $register_plus_redux->rpr_get_option( 'show_license' ) ) {465 $accept_license = isset( $_REQUEST['accept_license'] ) ? '1' : '0';466 echo "\n", '<input type="hidden" name="accept_license" value="', esc_attr($accept_license), '" />';467 }468 if ( '1' === $register_plus_redux->rpr_get_option( 'show_privacy_policy' ) ) {469 $accept_privacy_policy = isset( $_REQUEST['accept_privacy_policy'] ) ? '1' : '0';470 echo "\n", '<input type="hidden" name="accept_privacy_policy" value="', esc_attr($accept_privacy_policy), '" />';471 }472 }473 474 public /*.array[string]mixed.*/ function rpr_filter_wpmu_validate_user_signup( /*.array[string]mixed.*/ $result ) {475 global $register_plus_redux;476 global $pagenow;477 if ( $pagenow != 'wp-signup.php' ) return $result;478 //trigger_error( sprintf( __( 'Register Plus Redux DEBUG: filter_wpmu_validate_user_signup($result=%s) from %s', 'register-plus-redux' ), print_r($result), $pagenow ) );479 if ( '1' === $register_plus_redux->rpr_get_option( 'username_is_email' ) ) {480 global $wpdb;481 482 if ( is_array( $result['errors']->errors ) && isset( $result['errors']->errors['user_name'] ) ) unset( $result['errors']->errors['user_name'] );483 if ( is_array( $result['errors']->error_data ) && isset( $result['errors']->error_data['user_name'] ) ) unset( $result['errors']->error_data['user_name'] );484 485 $result['user_name'] = $result['user_email'];486 $result['orig_username'] = $result['user_email'];487 488 // Check if the username has been used already.489 if ( username_exists( $result['user_name'] ) )490 $result['errors']->add('user_email', __('Sorry, that username already exists!'));491 492 // Has someone already signed up for this username?493 /*.object.*/ $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_login = %s", $result['user_name'] ) );494 if ( !empty( $signup ) ) {495 // If registered more than two days ago, cancel registration and let this signup go through.496 if ( ( current_time( 'timestamp', TRUE ) - mysql2date('U', $signup->registered) ) > 2 * DAY_IN_SECONDS )497 $wpdb->delete( $wpdb->signups, array( 'user_login' => $result['user_name'] ) );498 else499 $result['errors']->add('user_email', __('That username is currently reserved but may be available in a couple of days.'));500 501 if ( $signup->active === 0 && $signup->user_email === $result['user_email'] )502 $result['errors']->add('user_email_used', __('username and email used'));503 }504 }505 if ( '1' === $register_plus_redux->rpr_get_option( 'double_check_email' ) ) {506 if ( empty( $_POST['user_email2'] ) ) {507 $result['errors']->add( 'user_email2', __( 'Please confirm your e-mail address.', 'register-plus-redux' ) );508 }509 elseif ( $_POST['user_email'] !== $_POST['user_email2'] ) {510 $result['errors']->add( 'user_email2', __( 'Your e-mail address does not match.', 'register-plus-redux' ) );511 }512 }513 if ( is_array( $register_plus_redux->rpr_get_option( 'required_fields' ) ) && in_array( 'first_name', $register_plus_redux->rpr_get_option( 'required_fields' ) ) ) {514 if ( empty( $_POST['first_name'] ) ) {515 $result['errors']->add( 'first_name', __( 'Please enter your first name.', 'register-plus-redux' ) );516 }517 }518 if ( is_array( $register_plus_redux->rpr_get_option( 'required_fields' ) ) && in_array( 'last_name', $register_plus_redux->rpr_get_option( 'required_fields' ) ) ) {519 if ( empty( $_POST['last_name'] ) ) {520 $result['errors']->add( 'last_name', __( 'Please enter your last name.', 'register-plus-redux' ) );521 }522 }523 if ( is_array( $register_plus_redux->rpr_get_option( 'required_fields' ) ) && in_array( 'user_url', $register_plus_redux->rpr_get_option( 'required_fields' ) ) ) {524 if ( empty( $_POST['user_url'] ) ) {525 $result['errors']->add( 'user_url', __( 'Please enter your website URL.', 'register-plus-redux' ) );526 }527 }528 if ( is_array( $register_plus_redux->rpr_get_option( 'required_fields' ) ) && in_array( 'aim', $register_plus_redux->rpr_get_option( 'required_fields' ) ) ) {529 if ( empty( $_POST['aim'] ) ) {530 $result['errors']->add( 'aim', __( 'Please enter your AIM username.', 'register-plus-redux' ) );531 }532 }533 if ( is_array( $register_plus_redux->rpr_get_option( 'required_fields' ) ) && in_array( 'yahoo', $register_plus_redux->rpr_get_option( 'required_fields' ) ) ) {534 if ( empty( $_POST['yahoo'] ) ) {535 $result['errors']->add( 'yahoo', __( 'Please enter your Yahoo IM username.', 'register-plus-redux' ) );536 }537 }538 if ( is_array( $register_plus_redux->rpr_get_option( 'required_fields' ) ) && in_array( 'jabber', $register_plus_redux->rpr_get_option( 'required_fields' ) ) ) {539 if ( empty( $_POST['jabber'] ) ) {540 $result['errors']->add( 'jabber', __( 'Please enter your Jabber / Google Talk username.', 'register-plus-redux' ) );541 }542 }543 if ( is_array( $register_plus_redux->rpr_get_option( 'required_fields' ) ) && in_array( 'about', $register_plus_redux->rpr_get_option( 'required_fields' ) ) ) {544 if ( empty( $_POST['description'] ) ) {545 $result['errors']->add( 'description', __( 'Please enter some information about yourself.', 'register-plus-redux' ) );546 }547 }548 $redux_usermeta = get_option( 'register_plus_redux_usermeta-rv2' );549 if ( is_array( $redux_usermeta ) ) {550 foreach ( $redux_usermeta as $meta_field ) {551 $meta_key = $meta_field['meta_key'];552 if ( !empty( $meta_field['show_on_registration'] ) && !empty( $meta_field['require_on_registration'] ) && empty( $_POST[$meta_key] ) ) {553 $result['errors']->add( $meta_key, sprintf( __( 'Please enter a value for %s.', 'register-plus-redux' ), $meta_field['label'] ) );554 }555 if ( !empty( $meta_field['show_on_registration'] ) && ( 'textbox' === $meta_field['display'] ) && !empty( $meta_field['options'] ) && !preg_match( $meta_field['options'], (string) $_POST[$meta_key] ) ) {556 $result['errors']->add( $meta_key, sprintf( __( 'Please enter new value for %s, value specified is not in the correct format.', 'register-plus-redux' ), $meta_field['label'] ) );557 }558 }559 }560 if ( '1' === $register_plus_redux->rpr_get_option( 'user_set_password' ) ) {561 if ( empty( $_POST['pass1'] ) ) {562 $result['errors']->add( 'pass1', __( 'Please enter a password.', 'register-plus-redux' ) );563 }564 elseif ( strlen( (string) $_POST['pass1'] ) < absint( $register_plus_redux->rpr_get_option( 'min_password_length' ) ) ) {565 $result['errors']->add( 'pass1', sprintf( __( 'Your password must be at least %d characters in length.', 'register-plus-redux' ), absint( $register_plus_redux->rpr_get_option( 'min_password_length' ) ) ) );566 }567 elseif ( '1' !== $register_plus_redux->rpr_get_option( 'disable_password_confirmation' ) && $_POST['pass1'] !== $_POST['pass2'] ) {568 $result['errors']->add( 'pass1', __( 'Your password does not match.', 'register-plus-redux' ) );569 }570 else {571 if ( isset( $_POST['pass2'] ) ) unset( $_POST['pass2'] );572 }573 }574 if ( '1' === $register_plus_redux->rpr_get_option( 'enable_invitation_code' ) ) {575 if ( empty( $_POST['invitation_code'] ) && '1' === $register_plus_redux->rpr_get_option( 'require_invitation_code' ) ) {576 $result['errors']->add( 'invitation_code', __( 'Please enter an invitation code.', 'register-plus-redux' ) );577 }578 elseif ( !empty( $_POST['invitation_code'] ) ) {579 $invitation_code_bank = get_option( 'register_plus_redux_invitation_code_bank-rv1' );580 if ( is_array( $invitation_code_bank ) ) {581 if ( '1' !== $register_plus_redux->rpr_get_option( 'invitation_code_case_sensitive' ) ) {582 $_POST['invitation_code'] = strtolower( (string) $_POST['invitation_code'] );583 foreach ( $invitation_code_bank as $index => $invitation_code )584 $invitation_code_bank[$index] = strtolower( $invitation_code );585 }586 if ( is_array( $invitation_code_bank ) && !in_array( (string) $_POST['invitation_code'], $invitation_code_bank ) ) {587 $result['errors']->add( 'invitation_code', __( 'That invitation code is invalid.', 'register-plus-redux' ) );588 }589 else {590 // reverts lowercase key to stored case591 $key = array_search( (string) $_POST['invitation_code'], $invitation_code_bank );592 $invitation_code_bank = get_option( 'register_plus_redux_invitation_code_bank-rv1' );593 $_POST['invitation_code'] = $invitation_code_bank[$key];594 if ( '1' === $register_plus_redux->rpr_get_option( 'invitation_code_unique' ) ) {595 global $wpdb;596 if ( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->usermeta WHERE meta_key = 'invitation_code' AND meta_value = %s;", (string) $_POST['invitation_code'] ) ) ) {597 $result['errors']->add( 'invitation_code', __( 'This invitation code is already in use, please enter a unique invitation code.', 'register-plus-redux' ) );598 }599 }600 }601 }602 }603 }604 if ( '1' === $register_plus_redux->rpr_get_option( 'show_disclaimer' ) && '1' === $register_plus_redux->rpr_get_option( 'require_disclaimer_agree' ) ) {605 if ( empty( $_POST['accept_disclaimer'] ) ) {606 $result['errors']->add( 'disclaimer', sprintf( __( 'Please accept the %s', 'register-plus-redux' ), esc_html( $register_plus_redux->rpr_get_option( 'message_disclaimer_title' ) ) ) . '.' );607 }608 }609 if ( '1' === $register_plus_redux->rpr_get_option( 'show_license' ) && '1' === $register_plus_redux->rpr_get_option( 'require_license_agree' ) ) {610 if ( empty( $_POST['accept_license'] ) ) {611 $result['errors']->add( 'license', sprintf( __( 'Please accept the %s', 'register-plus-redux' ), esc_html( $register_plus_redux->rpr_get_option( 'message_license_title' ) ) ) . '.' );612 }613 }614 if ( '1' === $register_plus_redux->rpr_get_option( 'show_privacy_policy' ) && '1' === $register_plus_redux->rpr_get_option( 'require_privacy_policy_agree' ) ) {615 if ( empty( $_POST['accept_privacy_policy'] ) ) {616 $result['errors']->add( 'privacy_policy', sprintf( __( 'Please accept the %s', 'register-plus-redux' ), esc_html( $register_plus_redux->rpr_get_option( 'message_privacy_policy_title' ) ) ) . '.' );617 }618 }619 return $result;620 }621 622 public /*.array[string]string.*/ function filter_add_signup_meta( /*.array[string]string.*/ $meta ) {623 foreach ( $_POST as $key => $value ) {624 $meta[$key] = $value;625 }626 $meta['signup_http_referer'] = $_SERVER['HTTP_REFERER'];627 $meta['signup_registered_from_ip'] = $_SERVER['REMOTE_ADDR'];628 $meta['signup_registered_from_host'] = gethostbyaddr( $_SERVER['REMOTE_ADDR'] );629 return $meta;630 }631 632 //TODO: Custom email verification messages here633 public /*.bool.*/ function filter_wpmu_signup_user_notification( /*.string.*/ $user, /*.string.*/ $user_email, /*.string.*/ $key, /*.array[string]string.*/ $meta ) {634 global $register_plus_redux;635 if ( '1' !== $register_plus_redux->rpr_get_option( 'verify_user_email' ) ) {636 $_REQUEST['key'] = $key;637 }638 return TRUE;639 640 $admin_email = get_site_option( 'admin_email' );641 if ( $admin_email == '' )642 $admin_email = 'support@' . $_SERVER['SERVER_NAME'];643 $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );644 $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";645 $message = sprintf( __( "To activate your user, please click the following link:\n\n%verification_url%\n\nAfter you activate, you will receive *another email* with your login." ), site_url( "wp-activate.php?key=$key" ) );646 $subject = sprintf( __( '[%from_name%] Activate %user_login%' ), $from_name, $user );647 wp_mail($user_email, $subject, $message, $message_headers);648 return TRUE;649 }650 651 public /*.bool.*/ function filter_wpmu_signup_blog_notification( /*.string.*/ $domain, /*.string.*/ $path, /*.string.*/ $title, /*.string.*/ $user, /*.string.*/ $user_email, /*.string.*/ $key, /*.array[string]string.*/ $meta ) {652 return $this->filter_wpmu_signup_user_notification( $user, $user_email, $key, $meta );653 }654 655 public /*.void.*/ function rpr_signup_finished() {656 global $register_plus_redux;657 402 if ( '1' === $register_plus_redux->rpr_get_option( 'required_fields_asterisk' ) ) { 658 403 ?> … … 744 489 <?php 745 490 } 746 if ( '1' === $register_plus_redux->rpr_get_option( 'verify_user_admin' ) && $register_plus_redux->rpr_get_option( 'message_verify_user_admin' ) ) {747 ?>748 <script type="text/javascript">749 jQuery(document).ready(function() {750 jQuery("#content").html("<?php echo $register_plus_redux->rpr_get_option( 'message_verify_user_admin' ) ?>");751 });752 </script>753 <?php754 }755 if ( '1' === $register_plus_redux->rpr_get_option( 'verify_user_email' ) && $register_plus_redux->rpr_get_option( 'message_verify_user_email' ) ) {756 ?>757 <script type="text/javascript">758 jQuery(document).ready(function() {759 jQuery("#content").html("<?php echo $register_plus_redux->rpr_get_option( 'message_verify_user_email' ) ?>");760 });761 </script>762 <?php763 }764 491 765 492 /*.array[]mixed.*/ $redux_usermeta = get_option( 'register_plus_redux_usermeta-rv2' ); … … 778 505 } 779 506 } 507 } 508 } 509 510 public /*.void.*/ function rpr_signup_hidden_fields() { 511 global $register_plus_redux; 512 if ( '1' === $register_plus_redux->rpr_get_option( 'double_check_email' ) ) { 513 $user_email2 = isset( $_REQUEST['user_email2'] ) ? (string) $_REQUEST['user_email2'] : ''; 514 echo "\n", '<input type="hidden" name="user_email2" value="', esc_attr($user_email2), '" />'; 515 } 516 if ( is_array( $register_plus_redux->rpr_get_option( 'show_fields' ) ) && in_array( 'first_name', $register_plus_redux->rpr_get_option( 'show_fields' ) ) ) { 517 $first_name = isset( $_REQUEST['first_name'] ) ? (string) $_REQUEST['first_name'] : ''; 518 echo "\n", '<input type="hidden" name="first_name" value="', esc_attr($first_name), '" />'; 519 } 520 if ( is_array( $register_plus_redux->rpr_get_option( 'show_fields' ) ) && in_array( 'last_name', $register_plus_redux->rpr_get_option( 'show_fields' ) ) ) { 521 $last_name = isset( $_REQUEST['last_name'] ) ? (string) $_REQUEST['last_name'] : ''; 522 echo "\n", '<input type="hidden" name="last_name" value="', esc_attr($last_name), '" />'; 523 } 524 if ( is_array( $register_plus_redux->rpr_get_option( 'show_fields' ) ) && in_array( 'user_url', $register_plus_redux->rpr_get_option( 'show_fields' ) ) ) { 525 $user_url = isset( $_REQUEST['user_url'] ) ? (string) $_REQUEST['user_url'] : ''; 526 echo "\n", '<input type="hidden" name="user_url" value="', esc_attr($user_url), '" />'; 527 } 528 if ( is_array( $register_plus_redux->rpr_get_option( 'show_fields' ) ) && in_array( 'aim', $register_plus_redux->rpr_get_option( 'show_fields' ) ) ) { 529 $aim = isset( $_REQUEST['aim'] ) ? (string) $_REQUEST['aim'] : ''; 530 echo "\n", '<input type="hidden" name="aim" value="', esc_attr($aim), '" />'; 531 } 532 if ( is_array( $register_plus_redux->rpr_get_option( 'show_fields' ) ) && in_array( 'yahoo', $register_plus_redux->rpr_get_option( 'show_fields' ) ) ) { 533 $yahoo = isset( $_REQUEST['yahoo'] ) ? (string) $_REQUEST['yahoo'] : ''; 534 echo "\n", '<input type="hidden" name="yahoo" value="', esc_attr($yahoo), '" />'; 535 } 536 if ( is_array( $register_plus_redux->rpr_get_option( 'show_fields' ) ) && in_array( 'jabber', $register_plus_redux->rpr_get_option( 'show_fields' ) ) ) { 537 $jabber = isset( $_REQUEST['jabber'] ) ? (string) $_REQUEST['jabber'] : ''; 538 echo "\n", '<input type="hidden" name="jabber" value="', esc_attr($jabber), '" />'; 539 } 540 if ( is_array( $register_plus_redux->rpr_get_option( 'show_fields' ) ) && in_array( 'about', $register_plus_redux->rpr_get_option( 'show_fields' ) ) ) { 541 $description = isset( $_REQUEST['description'] ) ? (string) $_REQUEST['description'] : ''; 542 echo "\n", '<input type="hidden" name="description" value="', esc_attr($description), '" />'; 543 } 544 545 $redux_usermeta = get_option( 'register_plus_redux_usermeta-rv2' ); 546 if ( is_array( $redux_usermeta ) ) { 547 foreach ( $redux_usermeta as $meta_field ) { 548 if ( !empty( $meta_field['show_on_registration'] ) ) { 549 $meta_key = esc_attr( $meta_field['meta_key'] ); 550 $meta_value = isset( $_REQUEST[$meta_key] ) ? (string) $_REQUEST[$meta_key] : ''; 551 echo "\n", '<input type="hidden" name="', $meta_key, '" value="', esc_attr($meta_value), '" />'; 552 } 553 } 554 } 555 556 if ( '1' === $register_plus_redux->rpr_get_option( 'user_set_password' ) ) { 557 $pass1 = isset( $_REQUEST['pass1'] ) ? (string) $_REQUEST['pass1'] : ''; 558 echo "\n", '<input type="hidden" name="pass1" value="', esc_attr($pass1), '" />'; 559 $pass2 = isset( $_REQUEST['pass2'] ) ? (string) $_REQUEST['pass2'] : ''; 560 echo "\n", '<input type="hidden" name="pass2" value="', esc_attr($pass2), '" />'; 561 } 562 if ( '1' === $register_plus_redux->rpr_get_option( 'enable_invitation_code' ) ) { 563 $invitation_code = isset( $_REQUEST['invitation_code'] ) ? (string) $_REQUEST['invitation_code'] : ''; 564 echo "\n", '<input type="hidden" name="invitation_code" value="', esc_attr($invitation_code), '" />'; 565 } 566 if ( '1' === $register_plus_redux->rpr_get_option( 'show_disclaimer' ) ) { 567 $accept_disclaimer = isset( $_REQUEST['accept_disclaimer'] ) ? '1' : '0'; 568 echo "\n", '<input type="hidden" name="accept_disclaimer" value="', esc_attr($accept_disclaimer), '" />'; 569 } 570 if ( '1' === $register_plus_redux->rpr_get_option( 'show_license' ) ) { 571 $accept_license = isset( $_REQUEST['accept_license'] ) ? '1' : '0'; 572 echo "\n", '<input type="hidden" name="accept_license" value="', esc_attr($accept_license), '" />'; 573 } 574 if ( '1' === $register_plus_redux->rpr_get_option( 'show_privacy_policy' ) ) { 575 $accept_privacy_policy = isset( $_REQUEST['accept_privacy_policy'] ) ? '1' : '0'; 576 echo "\n", '<input type="hidden" name="accept_privacy_policy" value="', esc_attr($accept_privacy_policy), '" />'; 577 } 578 } 579 580 public /*.array[string]mixed.*/ function rpr_filter_wpmu_validate_user_signup( /*.array[string]mixed.*/ $result ) { 581 global $register_plus_redux; 582 global $pagenow; 583 if ( $pagenow != 'wp-signup.php' ) return $result; 584 //trigger_error( sprintf( __( 'Register Plus Redux DEBUG: filter_wpmu_validate_user_signup($result=%s) from %s', 'register-plus-redux' ), print_r($result), $pagenow ) ); 585 if ( '1' === $register_plus_redux->rpr_get_option( 'username_is_email' ) ) { 586 global $wpdb; 587 588 if ( is_array( $result['errors']->errors ) && isset( $result['errors']->errors['user_name'] ) ) unset( $result['errors']->errors['user_name'] ); 589 if ( is_array( $result['errors']->error_data ) && isset( $result['errors']->error_data['user_name'] ) ) unset( $result['errors']->error_data['user_name'] ); 590 591 $result['user_name'] = $result['user_email']; 592 $result['orig_username'] = $result['user_email']; 593 594 // Check if the username has been used already. 595 if ( username_exists( $result['user_name'] ) ) 596 $result['errors']->add('user_email', __('Sorry, that username already exists!')); 597 598 // Has someone already signed up for this username? 599 /*.object.*/ $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_login = %s", $result['user_name'] ) ); 600 if ( !empty( $signup ) ) { 601 // If registered more than two days ago, cancel registration and let this signup go through. 602 if ( ( current_time( 'timestamp', TRUE ) - mysql2date('U', $signup->registered) ) > 2 * DAY_IN_SECONDS ) 603 $wpdb->delete( $wpdb->signups, array( 'user_login' => $result['user_name'] ) ); 604 else 605 $result['errors']->add('user_email', __('That username is currently reserved but may be available in a couple of days.')); 606 607 if ( $signup->active === 0 && $signup->user_email === $result['user_email'] ) 608 $result['errors']->add('user_email_used', __('username and email used')); 609 } 610 } 611 if ( '1' === $register_plus_redux->rpr_get_option( 'double_check_email' ) ) { 612 if ( empty( $_POST['user_email2'] ) ) { 613 $result['errors']->add( 'user_email2', __( 'Please confirm your e-mail address.', 'register-plus-redux' ) ); 614 } 615 elseif ( $_POST['user_email'] !== $_POST['user_email2'] ) { 616 $result['errors']->add( 'user_email2', __( 'Your e-mail address does not match.', 'register-plus-redux' ) ); 617 } 618 } 619 if ( is_array( $register_plus_redux->rpr_get_option( 'required_fields' ) ) && in_array( 'first_name', $register_plus_redux->rpr_get_option( 'required_fields' ) ) ) { 620 if ( empty( $_POST['first_name'] ) ) { 621 $result['errors']->add( 'first_name', __( 'Please enter your first name.', 'register-plus-redux' ) ); 622 } 623 } 624 if ( is_array( $register_plus_redux->rpr_get_option( 'required_fields' ) ) && in_array( 'last_name', $register_plus_redux->rpr_get_option( 'required_fields' ) ) ) { 625 if ( empty( $_POST['last_name'] ) ) { 626 $result['errors']->add( 'last_name', __( 'Please enter your last name.', 'register-plus-redux' ) ); 627 } 628 } 629 if ( is_array( $register_plus_redux->rpr_get_option( 'required_fields' ) ) && in_array( 'user_url', $register_plus_redux->rpr_get_option( 'required_fields' ) ) ) { 630 if ( empty( $_POST['user_url'] ) ) { 631 $result['errors']->add( 'user_url', __( 'Please enter your website URL.', 'register-plus-redux' ) ); 632 } 633 } 634 if ( is_array( $register_plus_redux->rpr_get_option( 'required_fields' ) ) && in_array( 'aim', $register_plus_redux->rpr_get_option( 'required_fields' ) ) ) { 635 if ( empty( $_POST['aim'] ) ) { 636 $result['errors']->add( 'aim', __( 'Please enter your AIM username.', 'register-plus-redux' ) ); 637 } 638 } 639 if ( is_array( $register_plus_redux->rpr_get_option( 'required_fields' ) ) && in_array( 'yahoo', $register_plus_redux->rpr_get_option( 'required_fields' ) ) ) { 640 if ( empty( $_POST['yahoo'] ) ) { 641 $result['errors']->add( 'yahoo', __( 'Please enter your Yahoo IM username.', 'register-plus-redux' ) ); 642 } 643 } 644 if ( is_array( $register_plus_redux->rpr_get_option( 'required_fields' ) ) && in_array( 'jabber', $register_plus_redux->rpr_get_option( 'required_fields' ) ) ) { 645 if ( empty( $_POST['jabber'] ) ) { 646 $result['errors']->add( 'jabber', __( 'Please enter your Jabber / Google Talk username.', 'register-plus-redux' ) ); 647 } 648 } 649 if ( is_array( $register_plus_redux->rpr_get_option( 'required_fields' ) ) && in_array( 'about', $register_plus_redux->rpr_get_option( 'required_fields' ) ) ) { 650 if ( empty( $_POST['description'] ) ) { 651 $result['errors']->add( 'description', __( 'Please enter some information about yourself.', 'register-plus-redux' ) ); 652 } 653 } 654 $redux_usermeta = get_option( 'register_plus_redux_usermeta-rv2' ); 655 if ( is_array( $redux_usermeta ) ) { 656 foreach ( $redux_usermeta as $meta_field ) { 657 $meta_key = $meta_field['meta_key']; 658 if ( !empty( $meta_field['show_on_registration'] ) && !empty( $meta_field['require_on_registration'] ) && empty( $_POST[$meta_key] ) ) { 659 $result['errors']->add( $meta_key, sprintf( __( 'Please enter a value for %s.', 'register-plus-redux' ), $meta_field['label'] ) ); 660 } 661 if ( !empty( $meta_field['show_on_registration'] ) && ( 'textbox' === $meta_field['display'] ) && !empty( $meta_field['options'] ) && !preg_match( $meta_field['options'], (string) $_POST[$meta_key] ) ) { 662 $result['errors']->add( $meta_key, sprintf( __( 'Please enter new value for %s, value specified is not in the correct format.', 'register-plus-redux' ), $meta_field['label'] ) ); 663 } 664 } 665 } 666 if ( '1' === $register_plus_redux->rpr_get_option( 'user_set_password' ) ) { 667 if ( empty( $_POST['pass1'] ) ) { 668 $result['errors']->add( 'pass1', __( 'Please enter a password.', 'register-plus-redux' ) ); 669 } 670 elseif ( strlen( (string) $_POST['pass1'] ) < absint( $register_plus_redux->rpr_get_option( 'min_password_length' ) ) ) { 671 $result['errors']->add( 'pass1', sprintf( __( 'Your password must be at least %d characters in length.', 'register-plus-redux' ), absint( $register_plus_redux->rpr_get_option( 'min_password_length' ) ) ) ); 672 } 673 elseif ( '1' !== $register_plus_redux->rpr_get_option( 'disable_password_confirmation' ) && $_POST['pass1'] !== $_POST['pass2'] ) { 674 $result['errors']->add( 'pass1', __( 'Your password does not match.', 'register-plus-redux' ) ); 675 } 676 else { 677 if ( isset( $_POST['pass2'] ) ) unset( $_POST['pass2'] ); 678 } 679 } 680 if ( '1' === $register_plus_redux->rpr_get_option( 'enable_invitation_code' ) ) { 681 if ( empty( $_POST['invitation_code'] ) && '1' === $register_plus_redux->rpr_get_option( 'require_invitation_code' ) ) { 682 $result['errors']->add( 'invitation_code', __( 'Please enter an invitation code.', 'register-plus-redux' ) ); 683 } 684 elseif ( !empty( $_POST['invitation_code'] ) ) { 685 $invitation_code_bank = get_option( 'register_plus_redux_invitation_code_bank-rv1' ); 686 if ( is_array( $invitation_code_bank ) ) { 687 if ( '1' !== $register_plus_redux->rpr_get_option( 'invitation_code_case_sensitive' ) ) { 688 $_POST['invitation_code'] = strtolower( (string) $_POST['invitation_code'] ); 689 foreach ( $invitation_code_bank as $index => $invitation_code ) 690 $invitation_code_bank[$index] = strtolower( $invitation_code ); 691 } 692 if ( is_array( $invitation_code_bank ) && !in_array( (string) $_POST['invitation_code'], $invitation_code_bank ) ) { 693 $result['errors']->add( 'invitation_code', __( 'That invitation code is invalid.', 'register-plus-redux' ) ); 694 } 695 else { 696 // reverts lowercase key to stored case 697 $key = array_search( (string) $_POST['invitation_code'], $invitation_code_bank ); 698 $invitation_code_bank = get_option( 'register_plus_redux_invitation_code_bank-rv1' ); 699 $_POST['invitation_code'] = $invitation_code_bank[$key]; 700 if ( '1' === $register_plus_redux->rpr_get_option( 'invitation_code_unique' ) ) { 701 global $wpdb; 702 if ( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->usermeta WHERE meta_key = 'invitation_code' AND meta_value = %s;", (string) $_POST['invitation_code'] ) ) ) { 703 $result['errors']->add( 'invitation_code', __( 'This invitation code is already in use, please enter a unique invitation code.', 'register-plus-redux' ) ); 704 } 705 } 706 } 707 } 708 } 709 } 710 if ( '1' === $register_plus_redux->rpr_get_option( 'show_disclaimer' ) && '1' === $register_plus_redux->rpr_get_option( 'require_disclaimer_agree' ) ) { 711 if ( empty( $_POST['accept_disclaimer'] ) ) { 712 $result['errors']->add( 'disclaimer', sprintf( __( 'Please accept the %s', 'register-plus-redux' ), esc_html( $register_plus_redux->rpr_get_option( 'message_disclaimer_title' ) ) ) . '.' ); 713 } 714 } 715 if ( '1' === $register_plus_redux->rpr_get_option( 'show_license' ) && '1' === $register_plus_redux->rpr_get_option( 'require_license_agree' ) ) { 716 if ( empty( $_POST['accept_license'] ) ) { 717 $result['errors']->add( 'license', sprintf( __( 'Please accept the %s', 'register-plus-redux' ), esc_html( $register_plus_redux->rpr_get_option( 'message_license_title' ) ) ) . '.' ); 718 } 719 } 720 if ( '1' === $register_plus_redux->rpr_get_option( 'show_privacy_policy' ) && '1' === $register_plus_redux->rpr_get_option( 'require_privacy_policy_agree' ) ) { 721 if ( empty( $_POST['accept_privacy_policy'] ) ) { 722 $result['errors']->add( 'privacy_policy', sprintf( __( 'Please accept the %s', 'register-plus-redux' ), esc_html( $register_plus_redux->rpr_get_option( 'message_privacy_policy_title' ) ) ) . '.' ); 723 } 724 } 725 return $result; 726 } 727 728 public /*.array[string]string.*/ function filter_add_signup_meta( /*.array[string]string.*/ $meta ) { 729 foreach ( $_POST as $key => $value ) { 730 $meta[$key] = $value; 731 } 732 $meta['signup_http_referer'] = $_SERVER['HTTP_REFERER']; 733 $meta['signup_registered_from_ip'] = $_SERVER['REMOTE_ADDR']; 734 $meta['signup_registered_from_host'] = gethostbyaddr( $_SERVER['REMOTE_ADDR'] ); 735 return $meta; 736 } 737 738 //TODO: Custom email verification messages here 739 public /*.bool.*/ function filter_wpmu_signup_user_notification( /*.string.*/ $user, /*.string.*/ $user_email, /*.string.*/ $key, /*.array[string]string.*/ $meta ) { 740 global $register_plus_redux; 741 if ( '1' !== $register_plus_redux->rpr_get_option( 'verify_user_email' ) ) { 742 $_REQUEST['key'] = $key; 743 } 744 return TRUE; 745 746 $admin_email = get_site_option( 'admin_email' ); 747 if ( $admin_email == '' ) 748 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; 749 $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) ); 750 $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 751 $message = sprintf( __( "To activate your user, please click the following link:\n\n%verification_url%\n\nAfter you activate, you will receive *another email* with your login." ), site_url( "wp-activate.php?key=$key" ) ); 752 $subject = sprintf( __( '[%from_name%] Activate %user_login%' ), $from_name, $user ); 753 wp_mail($user_email, $subject, $message, $message_headers); 754 return TRUE; 755 } 756 757 public /*.bool.*/ function filter_wpmu_signup_blog_notification( /*.string.*/ $domain, /*.string.*/ $path, /*.string.*/ $title, /*.string.*/ $user, /*.string.*/ $user_email, /*.string.*/ $key, /*.array[string]string.*/ $meta ) { 758 return $this->filter_wpmu_signup_user_notification( $user, $user_email, $key, $meta ); 759 } 760 761 public /*.void.*/ function rpr_signup_finished() { 762 global $register_plus_redux; 763 if ( '1' === $register_plus_redux->rpr_get_option( 'verify_user_admin' ) && $register_plus_redux->rpr_get_option( 'message_verify_user_admin' ) ) { 764 ?> 765 <script type="text/javascript"> 766 jQuery(document).ready(function() { 767 jQuery("#content").html("<?php echo $register_plus_redux->rpr_get_option( 'message_verify_user_admin' ) ?>"); 768 }); 769 </script> 770 <?php 771 } 772 if ( '1' === $register_plus_redux->rpr_get_option( 'verify_user_email' ) && $register_plus_redux->rpr_get_option( 'message_verify_user_email' ) ) { 773 ?> 774 <script type="text/javascript"> 775 jQuery(document).ready(function() { 776 jQuery("#content").html("<?php echo $register_plus_redux->rpr_get_option( 'message_verify_user_email' ) ?>"); 777 }); 778 </script> 779 <?php 780 780 } 781 781 }
Note: See TracChangeset
for help on using the changeset viewer.