Create a welcome email for newly added WordPress users

This is a welcome email plugin that needs to go into your plugins folder, create a file called something like welcome.php or welcome-email.php and paste the following code in to that file. The file then needs to be copied to your wp-content/plugins/ folder. Once uploaded login to your dashboard > plugins and look for the newly added plugin then activated it.

Now you will have more of a personalised message for your newly registered users. Changes can be made in the plugin to adapt the message you would like triggered.

<?php
/*
Plugin Name: Welcome Email
Plugin URI: http://www.squareonemd.co.uk/
Description: This plugin allows Administrators to change the standard WordPress welcome email.
Author: Elliott Richmond
Version: 1.0
Author URI: http://www.squareonemd.co.uk/
*/

// Redefine user notification function
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 );

		$message  = sprintf( __('New user registration on %s:'), get_option('blogname') ) . "\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'), get_option('blogname') ),
			$message
		);

		if ( empty( $plaintext_pass ) )
			return;

		$message  = __('Hi there ') . $user_login . "\r\n\r\n";
		$message .= sprintf( __("Welcome to %s! Here's how to log in and download your items:"), get_option('blogname')) . "\r\n\r\n";
		$message .= site_url('/wp-admin/') . "\r\n";
		$message .= sprintf( __('Username: %s'), $user_login ) . "\r\n";
		$message .= sprintf( __('Password: %s'), $plaintext_pass ) . "\r\n\r\n";
		// define your email addres in this line
		$message .= sprintf( __('If you have any problems, please contact us at %s.'), 'admin@youremaildomain.co.uk' ) . "\r\n\r\n";
		$message .= __('Adios!');

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

function sqpress_mail_from ($content_type) {
  // define the email address you want as the from field
  return 'admin@youremaildomain.co.uk';
}
add_filter('wp_mail_from','sqpress_mail_from');

function sqpress_mail_from_name($name) {
  // name of the account you want the email to appear in the client from field
  return 'SquarePress';
}
add_filter('wp_mail_from_name','sqpress_mail_from_name');

About

A geek who likes to cook with wp ingredients!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>