• Resolved phalancs

    (@phalancs)


    When using a user registration form with manual approval, a user receives an email when an admin has approved the account. I need to customize the text in this notification mail. Currently, it is the wrong language and does not fit my need.

    How can I customize it? Thanks in advance 🙂

    Dear XXXX,

    Your account on XXXXX has been activated! Please find your login details below.

    Login page: https://example.com

    Username: XXXXXX

    Password: Use the password that you submitted when registering your account, or set a new password at the link below.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Jair – WPMU DEV Support

    (@wpmudevsupport15)

    Hi @phalancs,

    I hope you are doing well today!

    This is the default WordPress notification email. To customize the email notification sent after the approval of user registration, you can use the following code snippet as mu-plugin.

    <?php
    add_filter(
    	'forminator_custom_form_user_registration_before_insert',
    	function ( $new_user_data ) {
    		add_action( 'user_register', 'wpmudev_forminator_filter_user_register_email', 10, 2 );
    
    		return $new_user_data;
    	}
    );
    
    
    function wpmudev_forminator_filter_user_register_email( int $user_id, array $userdata ) {
    	remove_action( 'user_register', 'wpmudev_forminator_filter_user_register_email' );
    
    	add_filter(
    		'wp_mail',
    		function ( array $mail_args ) use ( $user_id, $userdata ) {
    			$needle       = 'Account Activated';
    			$filter_email = substr( $mail_args['subject'], - strlen( $needle ) ) === $needle;
    
    			if ( $filter_email ) {
    				$userdata['user_id']  = $user_id;
    				$mail_args['message'] = wpmudev_forminator_registration_email_template( $userdata );
    				$mail_args['headers'] = array( 'Content-Type: text/html; charset=UTF-8' );
    
    				remove_action( 'user_register', 'wpmudev_forminator_filter_user_register_email', 10 );
    			}
    
    			return $mail_args;
    		}
    	);
    }
    
    
    function wpmudev_forminator_registration_email_template( array $user_data = array() ) {
    	if ( empty( $user_data ) ) {
    		return __( 'Hey! You have registered succesfully!' );
    	}
    
    	extract( $user_data );
    
    	$user            = get_user_by( 'id', $user_id );
    	$site_name       = get_bloginfo( 'name' );
    	$home_url        = home_url();
    	$login_page      = wp_login_url();
    	$key             = get_password_reset_key( $user );
    	$pass_reset_link = network_site_url( "wp-login.php?action=rp&key={$key}&login=" . rawurlencode( $user_login ), 'login' );
    
    
    	$tpl = "Dear {$user_login},
    
    <p>Your account on {$site_name} has been activated! Please find your login details below.</p>
    
    
    <p>Login page: {$login_page}</p>
    
    <p>Username: qwe2</p>
    
    <p>
    Password: Use the password that you submitted when registering your account, or set a new password at the link below.<br />
    <a href=\"{$pass_reset_link}\">{$pass_reset_link}</a>
    </p>
    
    
    <p>This message was sent from http://single2.local</p>";
    
    	do_action( 'retrieve_password_key', $user_login, $key );
    
    	return $tpl;
    }

    You can find more information below on how to use mu-plugins.
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins
    and
    https://ww.wp.xz.cn/support/article/must-use-plugins/

    Please let us know if you need further help or clarification on this.

    Kind regards,
    Zafer

    Hi @phalancs

    We haven’t heard from you in a while, I’ll go and mark this thread as resolved. If you have any additional questions or require further help, please let us know!

    Kind Regards,
    Kris

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

The topic ‘Customize “Account Activated” mail’ is closed to new replies.