Jump to content
Sign in to follow this  
yourgoal

How to send password to user email id

Recommended Posts

Hi,

 

I am using the php code as mentioned below to remove the verification email of the new user in my website which is powered by wordpress.

 

However, once the user registers he gets the user name and password on the website screen. I would like to disable this and display "Your password has been sent to your registered email id".

 

I want to user to check his email for the password.

 

  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. Copyright 2007-2009 Incsub (http://incsub.com)
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by
  14. the Free Software Foundation.
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU General Public License for more details.
  19. You should have received a copy of the GNU General Public License
  20. along with this program; if not, write to the Free Software
  21. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. // Remove existing filters - we need to do this in the whitelist_options filter because there isn't another action between
  24. // the built in MU one and the saving, besides which we need to add our new_admin_email field to the list anyway.
  25. add_filter('whitelist_options', 'remove_mu_option_hooks');
  26. // Blog signup - autoactivate
  27. add_filter( 'wpmu_signup_blog_notification', 'activate_on_blog_signup', 10, 7 );
  28. // User signup - autoactivate
  29. add_filter( 'wpmu_signup_user_notification', 'activate_on_user_signup', 10, 4 );
  30. // End activation message display
  31. add_action( 'signup_finished', 'activated_signup_finished', 1 );
  32. // Change internal confirmation message - user-new.php
  33. add_filter('gettext', 'activated_newuser_msg', 10, 3);
  34. //Remove BP activation emails.
  35. add_filter('wp_mail', 'remove_bp_activation_emails');
  36. function remove_bp_activation_emails($data) {
  37. 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') ) {
  38. unset( $data );
  39. $data['message'] = '';
  40. $data['to'] = '';
  41. $data['subject'] = '';
  42. }
  43. return $data;
  44. }
  45. function remove_mu_option_hooks($whitelist_options) {
  46. global $wp_filter;
  47. if(has_action('update_option_new_admin_email', 'update_option_new_admin_email')) {
  48. remove_action('update_option_new_admin_email', 'update_option_new_admin_email', 10, 2);
  49. // Add our own replacement action
  50. add_action('pre_update_option_new_admin_email', 'custom_update_option_new_admin_email', 10, 2);
  51. }
  52. $whitelist_options['general'][] = 'new_admin_email';
  53. return $whitelist_options;
  54. }
  55. function custom_update_option_new_admin_email($new_value, $old_value) {
  56. global $current_site;
  57. // Update the correct fields
  58. update_option('admin_email', $new_value);
  59. // Return the old value so that the new_admin_email option isn't set
  60. return $old_value;
  61. }
  62. function activate_on_blog_signup($domain, $path, $title, $user, $user_email, $key, $meta) {
  63. global $current_site;
  64. // Rather than recreate the wheel, just activate the blog immediately
  65. $result = wpmu_activate_signup($key);
  66. if ( is_wp_error($result) ) {
  67. if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
  68. $signup = $result->get_error_data();
  69. ?>
  70. <h2><?php _e('Congratulations! Your new blog is ready!'); ?></h2>
  71. <?php
  72. if( $signup->domain . $signup->path != '' ) {
  73. }
  74. } else {
  75. ?>
  76. <h2><?php _e('An error occurred during the signup'); ?></h2>
  77. <?php
  78. echo '<p>'.$result->get_error_message().'</p>';
  79. }
  80. } else {
  81. extract($result);
  82. $url = get_blogaddress_by_id( (int) $blog_id);
  83. $user = new WP_User( (int) $user_id);
  84. ?>
  85. <h2><?php _e('Congratulations! Your new blog is ready!'); ?></h2>
  86. <div id="signup-welcome">
  87. <p><span class="h3"><?php _e('Username:'); ?></span> <?php echo $user->user_login ?></p>
  88. <p><span class="h3"><?php _e('Password:'); ?></span> <?php echo $password; ?></p>
  89. </div>
  90. <?php if( !empty($url) ) : ?>
  91. <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>
  92. <?php else: ?>
  93. <?php endif;
  94. }
  95. // Now we need to hijack the sign up message so it isn't displayed
  96. ob_start();
  97. return false; // Returns false so that the activation email isn't sent out to the user
  98. }
  99. function activate_on_user_signup($user, $user_email, $key, $meta) {
  100. global $current_site, $current_blog;
  101. // Output buffer in case we need to email instead of output
  102. $html = '';
  103. // Rather than recreate the wheel, just activate the user immediately
  104. $result = wpmu_activate_signup($key);
  105. if ( is_wp_error($result) ) {
  106. if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
  107. $signup = $result->get_error_data();
  108. $html .= '<h2>' . __('Hello, your account has been created!') . "</h2>n";
  109. if( $signup->domain . $signup->path == '' ) {
  110. } else {
  111. }
  112. } else {
  113. $html .= '<h2>' . __('An error occurred during the signup') . "</h2>n";
  114. $html .= '<p>'.$result->get_error_message().'</p>';
  115. }
  116. } else {
  117. extract($result);
  118. $user = new WP_User( (int) $user_id);
  119. $html = '<h2>' . sprintf(__('Hello %s, your account has been created!'), $user->user_login ) . "</h2>n";
  120. $html .= '<div id="signup-welcome">';
  121. $html .= '<p><span class="h3">' . __('Username:') . '</span>' . $user->user_login . '</p>';
  122. $html .= '<p><span class="h3">' . __('Password:') . '</span>' . $password . '</p>';
  123. $html .= '</div>';
  124. }
  125. // Check if we are passed in an admin area
  126. if(!is_admin() || !(isset($_POST['_wp_http_referer']) && strstr($_POST['_wp_http_referer'], 'user-new.php'))) {
  127. echo $html;
  128. }
  129. // Now we need to hijack the sign up message so it isn't displayed
  130. ob_start();
  131. return false; // Returns false so that the activation email isn't sent out to the user
  132. }
  133. //Invitation email sent to new user. A confirmation link must be clicked before their account is created.
  134. function activated_newuser_msg($transtext, $normtext, $domain) {
  135. switch ($normtext) {
  136. // Plugin page text that we want to remove
  137. case 'Invitation email sent to new user. A confirmation link must be clicked before their account is created.':
  138. $transtext = __('The new user has been created and an email containing their account details has been sent to them.');
  139. break;
  140. 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>':
  141. $transtext = '';
  142. break;
  143. }
  144. return $transtext;
  145. }
  146. function activated_signup_finished() {
  147. // Flush the activation buffer
  148. ob_end_clean();
  149. }
  150. ?>

remove verification email.txt

Share this post


Link to post
Share on other sites

 

I am using the php code as mentioned below to remove the verification email of the new user in my website which is powered by wordpress.

 

However, once the user registers he gets the user name and password on the website screen. I would like to disable this and display "Your password has been sent to your registered email id".

 

I want to user to check his email for the password.

 

Why? You should never send a password through e-mail. There is no security in e-mail messages.

Share this post


Link to post
Share on other sites

That's just one of the problems using a framework.

Share this post


Link to post
Share on other sites

IF you want to change how the plugin works, then find the code you want to change and make it do what you want to do instead. If you search that code for "password" you'll see where it does that, and you can change it to have it send an email instead.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...