1. Home
  2. Snippets
  3. Send user email when registration is approved

Send user email when registration is approved

Heads up!

This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

For extra guidance, please see WPBeginner's tutorial on adding custom code.

Dismiss

In the WPForms User Registration addon settings, you can choose to manually approve any users who register to your WordPress site.

When this is enabled, the user will automatically receive an email to let them know their registration still needs to be activated by a site administrator. If you’d like, this email’s content can be customized.

To also send users an email when their registration has been approved, you can add the code below to your site. Then, be sure to adjust this code for your use (items marked with an asterisk * must be changed):

  • Email Subject
  • Email Message
  • From Name *
  • From Email Address *
/**
 * WPForms User Registration: Send user email when registration is approved.
 * 
 * @param int $user_id
 */
function wpf_dev_approval_email( $user_id ) {
	
	$user = get_userdata( $user_id );

	$subject = 'User Account Approved';
	$message = 'Hi There! We just wanted to let you know your user account on example.com has been approved.';

	// Send email with the WPForms email template.
	$emails = new WPForms_WP_Emails;
	$emails->__set( 'from_name', 'John Doe' );
	$emails->__set( 'from_address', 'john@example.com' ); // If using SMTP, be sure to use that email address here.
	$emails->send( $user->user_email, $subject, $message );
}
add_action( 'wpforms_user_approve', 'wpf_dev_approval_email' );

Additionally, the $message value can include HTML tags if you’d like.

Any notification email customizations you’ve set up for other form emails will be applied to this email as well.

Email when user registration is approved

Updated on March 21, 2018

Was this article helpful?