Can an email be sent containing user data from the sign up form once they have completed it?

Hi Team

Is it possible to get an email sent to admins once a signup form has been completed? The email would just need to contain all the data entered in the signup form.

Thanks

Chris

  • Rupok

    Hi Chris,

    Thanks for asking. I think it's possible with custom coding. Can you please follow the tutorial provided here? http://benpearson.com.au/customizing-the-new-user-registration-and-your-username-and-password-email-notifications-sent-by-wordpress/

    In that tutorial, you will see this line:
    $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n";
    You can add the following lines under that line:

    $message .= sprintf(__('E-mail: %s'), $user->first_name) . "\r\n";
        $message .= sprintf(__('E-mail: %s'), $user->last_name) . "\r\n";

    You can also add more details the user provided during the signup in the same way. And all will be emailed to the admin.

    I believe, this will help. Please let us know if you have any confusion or if you have any further query. We will be glad to help.

    Have a nice day. Cheers!
    Rupok

  • Kasia Swiderska

    Hello Chris,

    No, you don't edit this in wp-includes/pluggable.php - please take a look on the second part of that tutorial:

    This is a pluggable function so it can be customized by redefining it . Unfortunately redefining it in your theme has no effect, it needs to be replaced via a plugin.

    You can use Must Use plugin - http://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    You can copy example code provided in tutorial and add line that Rupok suggested here

    <?php
    /**
     * Plugin Name: Custom New User Notifications
     * Description: Customize the "New User Registration" and "Your username and password" notifications
     * Version: 1.0
     * Author: Ben Pearson
     * Author URI: http://benpearson.com.au
     */
    
    if ( !function_exists('wp_new_user_notification') ) :
    /**
     * Notify the blog admin of a new user, normally via email.
     *
     * @since 2.0
     *
     * param int $user_id User ID
     * param string $plaintext_pass Optional. The user's plaintext password
     */
    function wp_new_user_notification($user_id, $plaintext_pass = '') {
        $user = get_userdata( $user_id );
    
        // The blogname option is escaped with esc_html on the way into the database in sanitize_option
        // we want to reverse this for the plain text arena of emails.
        $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    
        $message  = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
        $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
        $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n";
    $message .= sprintf(__('First name: %s'), $user->first_name) . "\r\n";
        $message .= sprintf(__('Last name: %s'), $user->last_name) . "\r\n";
    
        @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
    
        if ( empty($plaintext_pass) )
            return;
    
        $message  = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
        $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
        $message .= wp_login_url() . "\r\n";
    
        wp_mail($user->user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);
    
    }
    endif;
    ?>

    Let me know if you have more questions

    kind regards,
    Kasia

  • Chris

    To be honest it doesn't. You must think I'm stupid.

    I need to create a new folder - got it. But what do I put in there? Nowhere does it say specifically?

    Do I create a text file with this (below) and put it in?

    <?php
    /**
    * Plugin Name: Custom New User Notifications
    * Description: Customize the "New User Registration" and "Your username and password" notifications
    * Version: 1.0
    * Author: Ben Pearson
    * Author URI: http://benpearson.com.au
    */

    if ( !function_exists('wp_new_user_notification') ) :
    /**
    * Notify the blog admin of a new user, normally via email.
    *
    * @since 2.0
    *
    * param int $user_id User ID
    * param string $plaintext_pass Optional. The user's plaintext password
    */
    function wp_new_user_notification($user_id, $plaintext_pass = '') {
    $user = get_userdata( $user_id );

    // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    // we want to reverse this for the plain text arena of emails.
    $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);

    $message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
    $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
    $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n";
    $message .= sprintf(__('First name: %s'), $user->first_name) . "\r\n";
    $message .= sprintf(__('Last name: %s'), $user->last_name) . "\r\n";

    @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);

    if ( empty($plaintext_pass) )
    return;

    $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
    $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
    $message .= wp_login_url() . "\r\n";

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

    }
    endif;
    ?>

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.