• I want to set my site up so that when a visitor registers on my site they are automatically sent a package of 6 downloadable e-books on internet marketing. How would I go about accomplishing that? any ideas? Thanks for taking the time to read this and double thanks if you reply.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    New users are sent a confirmation email via the wp_new_user_notification() function in wp-includes/pluggable.php around line 1188 for 3.4.1. As a pluggable function, just copy the whole function definition to your plugin, theme, or child theme, and it will override the default function.

    On your copy, edit the last call to wp_mail() to include the $attachements parameter, which is either an array of filenames or a newline delimited list of filenames to attach to the email. You’ll probably want to jazz up the other default email elements as well. It is all done by what’s passed to wp_mail().

    Thread Starter ugetpaid2

    (@ugetpaid2)

    LOL I’m already lost. How much will it cost me to get you to do this since you know all so well what you are talking about?

    I would put all your attachments in a single zip file upload it to somewhere like wp-cntent/uploads.
    then put this inside your functions.php file (make sure lines wrap and are not seperated.)

    function wp_new_user_notification($user_id, $plaintext_pass = '') {
            $attachments = array(WP_CONTENT_DIR . '/uploads/yourzipfile.zip');
            $user = new WP_User($user_id);
            $user_login = stripslashes($user->user_login);
            $user_email = stripslashes($user->user_email);
    
            // The blogname option is escaped with esc_html on the way into the databa
    se 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:'), $blognam
    e) . "\r\n\r\n";
            $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
            $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n";
    
            @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration
    '), $blogname), $message, $attachments);
    
            if ( empty($plaintext_pass) )
                    return;
    
            $message  = sprintf(__('Username: %s'), $user_login) . "\r\n";
            $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
            $message .= wp_login_url() . "\r\n";
    
            wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogn
    ame), $message);
    
    }

    I added $attachments to the wp_mail function call and identified the $attachments first line inside the function

    Please try https://jobs.wordpress.net/
    Topic now closed as per the Forum Rules

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘after registration’ is closed to new replies.