• Resolved muneebkiani

    (@muneebkiani)


    Hi, i am trying to update reply to headers using filter functions but somehow it is doesn’t work

    //change reply email and name
    function pixel_mod_reply_email($reply_email, $setting, $id, $email_to){
    	return 'vertrieb@schultes.eu'; 
    }
    add_filter('bnfw_reply_email_field','pixel_mod_reply_email', 10,2);
    
    function pixel_mod_reply_name($replyname, $setting, $id, $emails_to ){
    	return 'Vertrieb'; 
    }
    add_filter('bnfw_reply_name_field','pixel_mod_reply_name', 10,2);
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author bnfw

    (@voltronik)

    Hi @muneebkiani,
    Thanks for your message.

    Can you try the examples from this page instead and let me know if it works for you?
    https://betternotificationsforwp.com/documentation/compatibility/changing-name-email-transactional-notifications/

    Thread Starter muneebkiani

    (@muneebkiani)

    sorry, I already have these filters but what I need is different from email and reply-to-email.
    I have another small issue. for email (notification=email-changed) the email is always in plain text, despite setting it in HTML. I checked the received email and it states the content-type header is set to plain text.

    • This reply was modified 3 years, 6 months ago by muneebkiani.
    • This reply was modified 3 years, 6 months ago by muneebkiani.
    Thread Starter muneebkiani

    (@muneebkiani)

    I managed to fix the issue with the help of the following filter but it would really helpful if you add bn specific plugin so we can override headers only for specific notifications

    function pixel_mod_reply_email($args){
    	$headers[] = 'Content-type: text/html';
    	$headers[] = 'Reply-To: vertrieb <vertrieb@schultes.eu>';
    	$args['headers'] = $headers;
    	return $args;
    }
    add_filter('wp_mail','pixel_mod_reply_email', 10,2);
    Plugin Author bnfw

    (@voltronik)

    Hi @muneebkiani,
    You can override the email headers for each notification within BNFW which are supported by WordPress but if you want to override any others (those that can’t be filtered) then you’ll need to use a blanket function, such as the one I shared in my last reply.

    I’ll check the Email Changed notification and see why it’s not sending in HTML instead of plain text.

    Thread Starter muneebkiani

    (@muneebkiani)

    Thanks for your reply, text email issue has been resolved also.
    regarding the filter, I was referring to functions like this:

    /**
         * Send new user registration notification email.
         *
         * @since 1.1
         * @param array  $setting  Notification setting
         * @param object $user     User object
         * @param string $password_url Plain text password in WP < 4.3 and password url in WP > 4.3
         */
        public function send_registration_email( $setting, $user, $password_url = '' ) {
            /**
             * Whether to trigger welcome email notification or not.
             *
             * @since 1.7
             */
            $trigger_notification = apply_filters( 'bnfw_trigger_welcome-email_notification', true, $setting, $user );
    
            if ( ! $trigger_notification ) {
                return;
            }
    
            $user_id = $user->ID;
    
            $subject = $this->handle_shortcodes( $setting[ 'subject' ], $setting[ 'notification' ], $user_id );
            $message = $this->handle_shortcodes( $setting[ 'message' ], $setting[ 'notification' ], $user_id );
    
            $subject = str_replace( '[password]', $password_url, $subject );
            $message = str_replace( '[password]', $password_url, $message );
    
            $subject = str_replace( '[password_url]', $password_url, $subject );
            $message = str_replace( '[password_url]', $password_url, $message );
    
            $subject = str_replace( '[login_url]', wp_login_url(), $subject );
            $message = str_replace( '[login_url]', wp_login_url(), $message );
    
            if ( 'true' != $setting[ 'disable-autop' ] && 'html' == $setting[ 'email-formatting' ] ) {
                $message = wpautop( $message );
            }
    
            $headers = array();
            if ( 'html' == $setting[ 'email-formatting' ] ) {
                $headers[] = 'Content-type: text/html';
    			
                $message   = apply_filters( 'bnfw_registration_email_message', $message, $setting );
            } elseif ( 'text' == $setting[ 'email-formatting' ] ) {
                $message = strip_tags( $message );
            }
    
            $subject = $this->handle_global_user_shortcodes( $subject, $user->user_email );
            $message = $this->handle_global_user_shortcodes( $message, $user->user_email );
            wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
        }

    there is no way to override the reply-to header for a specific notification. I have managed to reset reply-to globally as a workaround for now. thanks for all the support.

    • This reply was modified 3 years, 6 months ago by muneebkiani.
    • This reply was modified 3 years, 6 months ago by muneebkiani. Reason: code block update
    Plugin Author bnfw

    (@voltronik)

    Hi @muneebkiani,
    Not a problem – glad you got it working.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘replyto headers’ is closed to new replies.