Support » Plugin: New User Approve » Mail tags not working in custom email message

  • Hi there!

    I’m using plugins filter to change email content, for example ‘new_user_approve_approve_user_message_default’ filter, but in received mail i get message with not processed tags, it looks like this:

    You have been approved to access {sitename} {username}
    To set your password, visit the following address: {reset_password_url}

    How I can make tags work in custom email ?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi, aarty20!
    Have you solved this problem? I have the same situation. Also, in the email de html content is not being interpreted, it is shown literally <html… 🙁
    Thanks!

    Hi, suvires.
    No, still not solved. I tried several times contact author of this plugin with no success. 🙁

    Finally, I solved it:

    /**
     * Modify the message sent to a user after being approved.
     *
     * @param $message The default message.
     * @param $user The user who will receive the message.
     * @return string the updated message.
     */
    function my_custom_approve_user_message( $message, $user ) {    
    
    		// send email to user telling of approval
    		$user_login = stripslashes( $user->data->user_login );
    		$user_email = stripslashes( $user->data->user_email );
        
        include('mails/email-registro-aprobado.php');    
        $message = nua_do_email_tags( $message, array(
    			'context' => 'approve_user',
    			'user' => $user,
    			'user_login' => $user_login,
    			'user_email' => $user_email,
    		) );
        return $message;
    }
    add_filter( 'new_user_approve_approve_user_message', 'my_custom_approve_user_message', 10, 2 );
    
    // add a new custom approval message
    function my_custom_request_appproval_message( $message, $user_login, $user_email = '' ) {            
        $default_admin_url = admin_url( 'users.php?s&pw-status-query-submit=Filter&new_user_approve_filter=pending&paged=1' );
    		$admin_url = apply_filters( 'new_user_approve_admin_link', $default_admin_url );
        $user = get_user_by('login', $user_login);
        include('mails/email-aprobacion.php');
        
        $message = nua_do_email_tags( $message, array(
    			'context' => 'request_admin_approval_email',
    			'user_login' => $user_login,
    			'user_email' => $user->user_email,
    			'admin_url' => $admin_url,
    		) );
    
        return $message;
    }
    add_filter( 'new_user_approve_request_approval_message', 'my_custom_request_appproval_message', 10, 2 );
     
    //quitar mensaje en /wp-login.php 
    function my_custom_approve_register_instructions() {
    	return '';
    } 
    add_filter( 'new_user_approve_welcome_message_default', 'my_custom_approve_register_instructions', 10, 2); 
     
    // remove denial message
    remove_action( 'new_user_approve_deny_user', array( pw_new_user_approve(), 'deny_user' ) );
    
    function wploop_email_content_type() {
    return 'text/html';
    }
    add_filter( 'wp_mail_content_type', 'wploop_email_content_type' );
    

    And the includes have de markups:
    {username}, {reset_password_url}, {admin_approve_url}, {user_email}

    [ link redacted ]

    • This reply was modified 2 years, 3 months ago by suvires.
    • This reply was modified 2 years, 3 months ago by Jan Dembowski.

    Hey suvires, I’m back again for this task. Big thanks for help with tags, now they works!

    I got one more question, did you send these emails as html ? I edited email, add tags, but in mail box I receive html as plain text:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    	<meta name="viewport" content="width=device-width">
    	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    ....

    You have to add this:

    function wploop_email_content_type() {
    return ‘text/html’;
    }
    add_filter( ‘wp_mail_content_type’, ‘wploop_email_content_type’ );

    to allow WordPress send html emails.

    Hey suvires, thanks for answer!
    I know about this function, but it enable html content type for all emails, which will be sent from site, even system emails for admins.
    And when you send plain email as html, all text fall into one line, and it looks weird.

    So, correct question, how can be enable html content type only for needed plugin ?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Mail tags not working in custom email message’ is closed to new replies.