Skip to content

Instantly share code, notes, and snippets.

@JarrydLong
Created November 7, 2024 10:19
Show Gist options
  • Save JarrydLong/ad33b1405c73f78d26c5ef37e8ca5bc8 to your computer and use it in GitHub Desktop.
Save JarrydLong/ad33b1405c73f78d26c5ef37e8ca5bc8 to your computer and use it in GitHub Desktop.
<?php //do not copy
/**
* Send a welcome email to the member when creating a new user from the admin dashboard
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function mypmpro_admin_after_member_created_email() {
if( ! empty( $_REQUEST['user_info_action'] ) && $_REQUEST['user_info_action'] == 'created' ){
$user_id = ! empty( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : 0;
if( ! $user_id ) {
return;
}
//Send an email using the mypmpro_admin_created_user template
$user = get_userdata( $user_id );
$email = new PMProEmail();
$email->email = $user->user_email;
$email->subject = 'Your account has been created';
$email->data = array(
'body' => 'Your account has been created. You can now login to the site using your username and password.',
);
$email->sendEmail();
}
}
add_action( 'admin_init', 'mypmpro_admin_after_member_created_email' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment