1
0

page-register.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. /**
  3. Template Name: 注册页面模版
  4. */
  5. get_header();
  6. if( !empty($_POST['register_reg']) ) {
  7. $error = '';
  8. $sanitized_user_login = sanitize_user( $_POST['user_login'] );
  9. $user_email = apply_filters( 'user_registration_email', $_POST['user_email'] );
  10. // Check the username
  11. if ( $sanitized_user_login == '' ) {
  12. $error .= '<strong>'.__("Error","sakurairo")./*错误*/'</strong>:'.__("Please enter username.","sakurairo")./*请输入用户名。*/'<br />';
  13. } elseif ( ! validate_username( $sanitized_user_login ) ) {
  14. $error .= '<strong>'.__("Error","sakurairo")./*错误*/'</strong>:'.__("Invalid characters, please enter a valid username.","sakurairo")./*此用户名包含无效字符,请输入有效的用户名。*/'<br />';
  15. $sanitized_user_login = '';
  16. } elseif ( username_exists( $sanitized_user_login ) ) {
  17. $error .= '<strong>'.__("Error","sakurairo")./*错误*/'</strong>:'.__("This username has been registered.","sakurairo")./*该用户名已被注册。*/'<br />';
  18. }
  19. // Check the e-mail address
  20. if ( $user_email == '' ) {
  21. $error .= '<strong>'.__("Error","sakurairo")./*错误*/'</strong>:'.__("Please enter email address.","sakurairo")./*请填写电子邮件地址。*/'<br />';
  22. } elseif ( ! is_email( $user_email ) ) {
  23. $error .= '<strong>'.__("Error","sakurairo")./*错误*/'</strong>:'.__("Invalid email address.","sakurairo")./*电子邮件地址不正确。*/'<br />';
  24. $user_email = '';
  25. } elseif ( email_exists( $user_email ) ) {
  26. $error .= '<strong>'.__("Error","sakurairo")./*错误*/'</strong>:'.__("This email address has been registered.","sakurairo")./*该电子邮件地址已经被注册。*/'<br />';
  27. }
  28. // Check the password
  29. if(strlen($_POST['user_pass']) < 6){
  30. $error .= '<strong>'.__("Error","sakurairo")./*错误*/'</strong>:'.__("Password length is at least 6 digits.","sakurairo")./*密码长度至少6位。*/'<br />';
  31. }elseif($_POST['user_pass'] != $_POST['user_pass2']){
  32. $error .= '<strong>'.__("Error","sakurairo")./*错误*/'</strong>:'.__("Inconsistent password entered twice.","sakurairo")./*两次输入的密码不一致。*/'<br />';
  33. }
  34. if($error == '') {
  35. $user_id = wp_create_user( $sanitized_user_login, $_POST['user_pass'], $user_email );
  36. if ( !$user_id ) {
  37. $error .= '<strong>'.__("Error","sakurairo")./*错误*/'</strong>:'.__("Unable to complete registration request...Please contact","sakurairo")./*无法完成注册请求... 请联系*/'<a href=\"mailto:'. get_option( 'admin_email' ) .'\">'.__("administrator","sakurairo")./*管理员*/'</a>!<br />';
  38. }else if (!is_user_logged_in()) {
  39. $user = get_userdatabylogin($sanitized_user_login);
  40. $user_id = $user->ID;
  41. // 自动登录
  42. wp_set_current_user($user_id, $user_login);
  43. wp_set_auth_cookie($user_id);
  44. do_action('wp_login', $user_login);
  45. }
  46. }
  47. }
  48. ?>
  49. <div id="primary" class="content-area">
  50. <main id="main" class="site-main" role="main">
  51. <?php if(iro_opt('ex_register_open')) : ?>
  52. <?php if(!is_user_logged_in()){ ?>
  53. <div class="ex-register">
  54. <div class="ex-register-title">
  55. <h3>New Account</h3>
  56. </div>
  57. <form action="<?php echo $_SERVER["REQUEST_URI"]; ?>" method="post">
  58. <p><input type="text" name="user_login" tabindex="1" id="user_login" class="input" value="<?php if(!empty($sanitized_user_login)) echo $sanitized_user_login; ?>" placeholder="<?php _e("User Name",'sakurairo'); ?>" required /></p>
  59. <p><input type="text" name="user_email" tabindex="2" id="user_email" class="input" value="<?php if(!empty($user_email)) echo $user_email; ?>" size="25" placeholder="<?php _e("Email Address","sakurairo");?>" required /></p>
  60. <p><input id="user_pwd1" class="input" tabindex="3" type="password" tabindex="21" size="25" value="" name="user_pass" placeholder="<?php _e("Password","sakurairo");?>" required /></p>
  61. <p><input id="user_pwd2" class="input" tabindex="4" type="password" tabindex="21" size="25" value="" name="user_pass2" placeholder="<?php _e("Confirm your password","sakurairo");?>" required /></p>
  62. <input type="hidden" name="register_reg" value="ok" />
  63. <?php if(!empty($error)) { echo '<p class="user-error">'.$error.'</p>'; } ?>
  64. <input class="button register-button" name="submit" type="submit" value="<?php _e("Sign up","sakurairo")/*注 册*/?>">
  65. </form>
  66. </div>
  67. <?php }else{
  68. $loadurl = iro_opt('exlogin_url') ? iro_opt('exlogin_url') : get_bloginfo('url');
  69. ?>
  70. <div class="ex-register-title">
  71. <h3><?php _e("Success! Redirecting......","sakurairo")/*注册成功!正在跳转...*/?></h3>
  72. </div>
  73. <script>window.location.href='<?php echo $loadurl; ?>';</script>
  74. <?php } ?>
  75. <?php else : ?>
  76. <div class="register-close"><p><?php _e("Registration is not open yet.","sakurairo")/*暂未开放注册。*/?></p></div>
  77. <?php endif; ?>
  78. </main><!-- #main -->
  79. </div><!-- #primary -->
  80. <style>
  81. #slider {
  82. margin: 0 auto 20px auto;
  83. width: 300px;
  84. height: 46px;
  85. position: relative;
  86. border-radius: 3px;
  87. background-color: #eee;
  88. overflow: hidden;
  89. text-align: center;
  90. user-select: none;
  91. -moz-user-select: none;
  92. -webkit-user-select: none;
  93. }
  94. #slider_bg {
  95. position: absolute;
  96. left: 0;
  97. top: 0;
  98. height: 100%;
  99. background-color: #444;
  100. z-index: 1;
  101. border-radius: 3px 0 0 3px;
  102. }
  103. #label {
  104. width: 46px;
  105. position: absolute;
  106. left: 0;
  107. top: 0;
  108. height: 46px;
  109. line-height: 38px;
  110. border: 1px solid #ddd;
  111. background: #fff;
  112. z-index: 3;
  113. cursor: move;
  114. color: #E67474;
  115. font-size: 38px;
  116. font-weight: 900;
  117. border-radius: 3px;
  118. }
  119. #labelTip {
  120. position: absolute;
  121. left: 0;
  122. width: 100%;
  123. height: 100%;
  124. font-size: 13px;
  125. font-family: 'Microsoft Yahei', serif;
  126. color: #888;
  127. line-height: 46px;
  128. text-align: center;
  129. z-index: 2;
  130. }
  131. #verification-slider{
  132. margin: 1em;
  133. }
  134. #verification-ok{
  135. color: #777;
  136. }
  137. </style>
  138. <?php
  139. get_footer();
  140. ?>