Advertisement
Guest User

Untitled

a guest
Dec 19th, 2010
12,150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.18 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Remove Email Verification
  4. Plugin URI:
  5. Description: This plugin automatically activates user and blog signups, effectively disabling the need for the user to respond to an email
  6. Author: Barry at clearskys.net (Incsub)
  7. Version: 1.0.3
  8. Author URI:
  9. */
  10.  
  11. /*
  12. Copyright 2007-2009 Incsub (http://incsub.com)
  13.  
  14. This program is free software; you can redistribute it and/or modify
  15. it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by
  16. the Free Software Foundation.
  17.  
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program; if not, write to the Free Software
  25. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  26. */
  27.  
  28. // Remove existing filters - we need to do this in the whitelist_options filter because there isn't another action between
  29. // the built in MU one and the saving, besides which we need to add our new_admin_email field to the list anyway.
  30. add_filter('whitelist_options', 'remove_mu_option_hooks');
  31. // Blog signup - autoactivate
  32. add_filter( 'wpmu_signup_blog_notification', 'activate_on_blog_signup', 10, 7 );
  33. // User signup - autoactivate
  34. add_filter( 'wpmu_signup_user_notification', 'activate_on_user_signup', 10, 4 );
  35. // End activation message display
  36. add_action( 'signup_finished', 'activated_signup_finished', 1 );
  37. // Change internal confirmation message - user-new.php
  38. add_filter('gettext', 'activated_newuser_msg', 10, 3);
  39. //Remove BP activation emails.
  40. add_filter('wp_mail', 'remove_bp_activation_emails');
  41.  
  42. function remove_bp_activation_emails($data) {
  43. if ( strstr($data['message'], 'To activate your user, please click the following link') || strstr($data['message'], 'To activate your blog, please click the following link') ) {
  44. unset( $data );
  45. $data['message'] = '';
  46. $data['to'] = '';
  47. $data['subject'] = '';
  48. }
  49. return $data;
  50. }
  51.  
  52. function remove_mu_option_hooks($whitelist_options) {
  53. global $wp_filter;
  54.  
  55. if(has_action('update_option_new_admin_email', 'update_option_new_admin_email')) {
  56. remove_action('update_option_new_admin_email', 'update_option_new_admin_email', 10, 2);
  57. // Add our own replacement action
  58. add_action('pre_update_option_new_admin_email', 'custom_update_option_new_admin_email', 10, 2);
  59. }
  60.  
  61. $whitelist_options['general'][] = 'new_admin_email';
  62.  
  63. return $whitelist_options;
  64.  
  65. }
  66.  
  67. function custom_update_option_new_admin_email($new_value, $old_value) {
  68. global $current_site;
  69.  
  70. // Update the correct fields
  71. update_option('admin_email', $new_value);
  72. // Return the old value so that the new_admin_email option isn't set
  73. return $old_value;
  74. }
  75.  
  76. function activate_on_blog_signup($domain, $path, $title, $user, $user_email, $key, $meta) {
  77.  
  78. global $current_site;
  79.  
  80. // Rather than recreate the wheel, just activate the blog immediately
  81. $result = wpmu_activate_signup($key);
  82.  
  83. if ( is_wp_error($result) ) {
  84. if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
  85. $signup = $result->get_error_data();
  86. ?>
  87. <h2><?php _e('Congratulations! Your new blog is ready!'); ?></h2>
  88.  
  89. <?php
  90. if( $signup->domain . $signup->path != '' ) {
  91. printf(__('<p class="lead-in">Your blog at <a href="%1$s">%2$s</a> is active. You may now login to your blog using your chosen username of "%3$s". Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.</p>'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, 'http://' . $current_site->domain . $current_site->path . 'wp-login.php?action=lostpassword');
  92. }
  93. } else {
  94. ?>
  95. <h2><?php _e('An error occurred during the signup'); ?></h2>
  96. <?php
  97. echo '<p>'.$result->get_error_message().'</p>';
  98. }
  99. } else {
  100. extract($result);
  101.  
  102. $url = get_blogaddress_by_id( (int) $blog_id);
  103. $user = new WP_User( (int) $user_id);
  104. ?>
  105. <h2><?php _e('Congratulations! Your new blog is ready!'); ?></h2>
  106.  
  107. <div id="signup-welcome">
  108. <p><span class="h3"><?php _e('Username:'); ?></span> <?php echo $user->user_login ?></p>
  109. <p><span class="h3"><?php _e('Password:'); ?></span> <?php echo $password; ?></p>
  110. </div>
  111.  
  112. <?php if( !empty($url) ) : ?>
  113. <p class="view"><?php printf(__('You\'re all set up and ready to go. <a href="%1$s">View your site</a> or <a href="%2$s">Login</a>'), $url, $url . 'wp-login.php' ); ?></p>
  114. <?php else: ?>
  115. <p class="view"><?php printf( __( 'You\'re all set up and ready to go. <a href="%1$s">Login</a> or go back to the <a href="%2$s">homepage</a>.' ), 'http://' . $current_site->domain . $current_site->path . 'wp-login.php', 'http://' . $current_site->domain . $current_site->path ); ?></p>
  116. <?php endif;
  117. }
  118.  
  119. // Now we need to hijack the sign up message so it isn't displayed
  120. ob_start();
  121.  
  122. return false; // Returns false so that the activation email isn't sent out to the user
  123. }
  124.  
  125. function activate_on_user_signup($user, $user_email, $key, $meta) {
  126.  
  127. global $current_site, $current_blog;
  128.  
  129. // Output buffer in case we need to email instead of output
  130. $html = '';
  131.  
  132. // Rather than recreate the wheel, just activate the user immediately
  133. $result = wpmu_activate_signup($key);
  134.  
  135. if ( is_wp_error($result) ) {
  136. if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
  137. $signup = $result->get_error_data();
  138. $html .= '<h2>' . __('Hello, your account has been created!') . "</h2>\n";
  139. if( $signup->domain . $signup->path == '' ) {
  140. $html .= sprintf(__('<p class="lead-in">Your account has been activated. You may now <a href="%1$s">login</a> to the site using your chosen username of "%2$s". Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.</p>'), 'http://' . $current_blog->domain . $current_blog->path . 'wp-login.php', $signup->user_login, $signup->user_email, 'http://' . $current_blog->domain . $current_blog->path . 'wp-login.php?action=lostpassword');
  141. } else {
  142. $html .= sprintf(__('<p class="lead-in">Your account at <a href="%1$s">%2$s</a> is active. You may now login to your account using your chosen username of "%3$s". Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.</p>'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, 'http://' . $current_blog->domain . $current_blog->path . 'wp-login.php?action=lostpassword');
  143. }
  144. } else {
  145.  
  146. $html .= '<h2>' . __('An error occurred during the signup') . "</h2>\n";
  147. $html .= '<p>'.$result->get_error_message().'</p>';
  148. }
  149. } else {
  150. extract($result);
  151.  
  152. $user = new WP_User( (int) $user_id);
  153.  
  154. $html = '<h2>' . sprintf(__('Hello %s, your account has been created!'), $user->user_login ) . "</h2>\n";
  155.  
  156. $html .= '<div id="signup-welcome">';
  157. $html .= '<p><span class="h3">' . __('Username:') . '</span>' . $user->user_login . '</p>';
  158. $html .= '<p><span class="h3">' . __('Password:') . '</span>' . $password . '</p>';
  159. $html .= '</div>';
  160.  
  161. $html .= '<p class="view">' . sprintf( __( 'You can now update your details by <a href="%1$s">Logging in</a> to your account or go back to the <a href="%2$s">homepage</a>.' ), 'http://' . $current_blog->domain . $current_blog->path . 'wp-login.php', 'http://' . $current_blog->domain . $current_blog->path ) . '</p>';
  162.  
  163. }
  164.  
  165. // Check if we are passed in an admin area
  166. if(!is_admin() || !(isset($_POST['_wp_http_referer']) && strstr($_POST['_wp_http_referer'], 'user-new.php'))) {
  167. echo $html;
  168. }
  169.  
  170. // Now we need to hijack the sign up message so it isn't displayed
  171. ob_start();
  172.  
  173. return false; // Returns false so that the activation email isn't sent out to the user
  174. }
  175.  
  176. //Invitation email sent to new user. A confirmation link must be clicked before their account is created.
  177. function activated_newuser_msg($transtext, $normtext, $domain) {
  178.  
  179. switch ($normtext) {
  180. // Plugin page text that we want to remove
  181. case 'Invitation email sent to new user. A confirmation link must be clicked before their account is created.':
  182. $transtext = __('The new user has been created and an email containing their account details has been sent to them.');
  183. break;
  184. case 'If you change this we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>':
  185. $transtext = '';
  186. break;
  187. }
  188.  
  189. return $transtext;
  190.  
  191. }
  192.  
  193.  
  194. function activated_signup_finished() {
  195. // Flush the activation buffer
  196. ob_end_clean();
  197. }
  198. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement