WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to have new user password sent to admin before user (7 posts)

  1. kameyers
    Member
    Posted 7 years ago #

    I currently upgraded to WP 2.1. Is there a way to configure the automated emails to be sent to the administrator before being sent to the newly register users?

    I want to allow anyone to register for my blog.

    Upon registering I want their email and username/password to be sent to me.

    After reviewing the information, I can manually forward their information to them.

    Is this possibe? I was in previous versions of WP, however, I'm having a harder time doing this with 2.1.

    Thanks for giving a newbie a helping hand.

  2. kameyers
    Member
    Posted 7 years ago #

    I felt that my first post was somewhat unclear. I have found a post that describes exactly what I want, however, WP 2.1 does not have wp-includes/pluggable-functions.php.

    I found a solution that worked for me. Instead of having the email with the username and password be sent to the registrant, I tweaked it so that it comes to me. If I want to approve the user I then just forward the email on to the user. Here is a summary of what I changed:

    In wp-includes/pluggable-functions.php

    I changed this function on line 427 or so from this:

    wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message);

    To this:

    wp_mail('webmaster@mydomain', sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message);

    So the user does not get their username and password without me sending it to them. This could probably be turned into a plugin pretty easily...and would do it when I have some time.

    http://wordpress.org/support/topic/35703?replies=7

  3. kameyers
    Member
    Posted 7 years ago #

    Ok, I got to playing around with some stuff, and I found this segment of code in wp-includes/pluggable.php, around line 468:


    wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message);

    change it to this:


    wp_mail('youremail@domain.com', sprintf(__('[%s] Your username and password'), get_option('blogname')), $message);

    I am not a guru at this stuff and my knowledge didn't solve the problem. I just fine tuned what another member, kwesitn, discovered. The credit goes to that person.

    I hope this helps someone other than myself.

  4. murray1974
    Member
    Posted 7 years ago #

    Helped me out! An indirect workaround for my problem! Thanks!

  5. sengwad
    Member
    Posted 7 years ago #

    I've been looking for a way to approve new users. This was a great start. I made a few more changes to suite my needs more directly. Here are the changes I made:

    if ( !function_exists('wp_new_user_notification') ) :
    function wp_new_user_notification($user_id, $plaintext_pass = '') {
    $user = new WP_User($user_id);

    $user_login = stripslashes($user->user_login);
    $user_email = stripslashes($user->user_email);

    $admin_email = get_option('admin_email');

    $message = sprintf(__('New user registration on your site, %s:'), get_option('blogname')) . "\r\n\r\n";
    $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
    $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
    $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";

    @wp_mail(get_option('admin_email'), sprintf(__('[%s] REGISTRATION APROVAL FORWARD TO USER'), get_option('blogname')), $message);

    if ( empty($plaintext_pass) )
    return;

    $message = sprintf(__('You will recieve your password shortly %s'), $user_login) . "\r\n";

    wp_mail($user_email, sprintf(__('[%s] Thanks for Registering'), get_option('blogname')), $message);

    }

    This code sends a message to the user notifying them that they will recieve their password shortly. An email is sent to the administrator (whatever email is set for the admin) notofying them someone has registered. It includes the username, password and email of the new user. Then, if the admin wants to aprove that user, they simply forward that email to the user. Works fine so far, hope that helps.

    -matt

  6. brwneyes
    Member
    Posted 7 years ago #

    Matt,

    This sounds like it would work for me too...can you help me out in letting me know what file you modified and what code you replaced, or if you just added to something...I am not an expert with PHP but I can copy and paste :-)

    If you can help me with some details, I would really appreciate it.

    Thanks so much!

  7. brwneyes
    Member
    Posted 7 years ago #

    Nevermind, I figured it out. I just tried it and it works for me also. Thank you Matt!

Topic Closed

This topic has been closed to new replies.

About this Topic