Title: Duplicate approval emails when using invitation code
Last modified: March 31, 2025

---

# Duplicate approval emails when using invitation code

 *  Resolved [franzif](https://wordpress.org/support/users/franzif/)
 * (@franzif)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/duplicate-approval-emails-when-using-invitation-code/)
 * Hi,
 * I’m using the Pro version of _New User Approve_ with both the **invitation code**
   and **domain whitelist** features enabled.
 * When a user registers with a valid code, they are approved automatically — but
   they receive **two approval emails** at the same time:
    - The first email contains an **empty password field**.
    - The second email is identical, except that it includes the **correctly generated
      password**.
 * This does **not** happen when users are approved manually — only with the automatic
   approval. It seems the approval email is triggered twice: once before and once
   after the password is set.
 * Can you advise how to prevent this?
 * Thanks, Franzi

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Support [Mirza Hamza Baig](https://wordpress.org/support/users/hamzawpexperts/)
 * (@hamzawpexperts)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/duplicate-approval-emails-when-using-invitation-code/#post-18394043)
 * Hello [@franzif](https://wordpress.org/support/users/franzif/),
 * Thanks for contacting us,
 * I hope you are doing well, We’ve informed our technical team about your issue,
   and they will work on it promptly. When we receive their response, we will get
   back to you. Our team is here to assist you. Thank you for your patience.
 * Thanks & Regards
   WP Experts Support Team
 *  Plugin Support [Mirza Hamza Baig](https://wordpress.org/support/users/hamzawpexperts/)
 * (@hamzawpexperts)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/duplicate-approval-emails-when-using-invitation-code/#post-18398916)
 * Hi [@franzif](https://wordpress.org/support/users/franzif/),
 * Please try to implement the following code in functions.php file into the active
   theme.
 * Here is the code:
 *     ```wp-block-code
       if(class_exists('PW_New_User_Approve')) {	$nua = NUA_USER_ROLE::instance();	remove_filter('new_user_approve_default_status', array($nua, 'role_base_auto_approval_of_user' ), 10, 2);	add_filter('new_user_approve_default_status',  'nua_role_base_auto_approval_of_user' , 10, 2);	function nua_role_base_auto_approval_of_user( $status, $user_id  ) {		// approve status after user is register by invitation code.		if ( ! empty( $_POST['nua_invitation_code'] ) ) {			$status = 'approved';			return $status;		}		// update user new role		$user_meta = new WP_User( $user_id );		// if the select role field is enabled		if( isset( $_POST['nua_user_role'] ) ) {  			foreach ( $user_meta->roles as $val ) {				$user_meta->remove_role( $val );			}			$selected_role = sanitize_text_field($_POST['nua_user_role']); // selected role from a field.			$user_meta->add_role( $selected_role );		}		$options = get_option( 'new_user_approve_options' );		$auto_approve_role_list = isset( $options['nua_auto_approve_role_list'] ) ? $options['nua_auto_approve_role_list'] : array();		$user_roles = $user_meta->roles;		$status = 'pending';		foreach ( $user_roles as $role ) {			if ( in_array( $role, $auto_approve_role_list ) ) {				$status = 'approved';				break;			}		}		// to show auto  message above reg form when user auto new_user_approved		do_action( 'role_base_approval_completed', $user_id, $user_roles, $auto_approve_role_list, $status );		return $status;	}}
       ```
   
 * If you have any questions, feel free to reach out. We’re here to assist you.
 * Thank you
 *  Thread Starter [franzif](https://wordpress.org/support/users/franzif/)
 * (@franzif)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/duplicate-approval-emails-when-using-invitation-code/#post-18399172)
 * Thank you so much for your support!
 * The custom code you provided successfully resolved the issue with the duplicate
   email. However, I noticed that the password field in the email remained empty.
 * To work around this, I’ve now added a password field directly to the registration
   form so users can set their password during registration. This works perfectly
   for my use case.
 * Thanks again, also to the technical team!
 *  Plugin Support [Mirza Hamza Baig](https://wordpress.org/support/users/hamzawpexperts/)
 * (@hamzawpexperts)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/duplicate-approval-emails-when-using-invitation-code/#post-18399293)
 * Hi [@franzif](https://wordpress.org/support/users/franzif/),
 * Thanks for the update. We would greatly appreciate your kind and honest review.
   Your feedback is important to us and can help other users make informed decisions
   about our products and services. Thank you for taking the time to share your 
   thoughts.
 * Thank you

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Duplicate approval emails when using invitation code’ is closed to new
replies.

 * ![](https://ps.w.org/new-user-approve/assets/icon-128x128.gif?rev=2544141)
 * [New User Approve](https://wordpress.org/plugins/new-user-approve/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/new-user-approve/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/new-user-approve/)
 * [Active Topics](https://wordpress.org/support/plugin/new-user-approve/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/new-user-approve/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/new-user-approve/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Mirza Hamza Baig](https://wordpress.org/support/users/hamzawpexperts/)
 * Last activity: [1 year, 2 months ago](https://wordpress.org/support/topic/duplicate-approval-emails-when-using-invitation-code/#post-18399293)
 * Status: resolved