dimanche 10 janvier 2016

wp_new_user_notification overrite e-mail

It seems during one of the last updates over the last 12 months it has now caused the below code not to work. I have tried to Google but can't seem to find a fix. I used this code in a custom plugin.

What is the new version of this code?

Code:

if ( !function_exists( 'wp_new_user_notification' ) ) {
    function wp_new_user_notification( $user_id, $plaintext_pass = '' ) {

        // set content type to html
        add_filter( 'wp_mail_content_type', 'wpmail_content_type' );

        // user
        $user                   = new WP_User( $user_id );
        $userEmail              = stripslashes( $user->user_email );

        $single             = true;
        $first_name_key = 'billing_first_name';
        $company_key    = 'billing_company';


        $first_name  = get_user_meta($user_id, $first_name_key, $single);
        $company     = get_user_meta($user_id, $company_key, $single);




        $subject = 'New User'." ".$first_name. " ". $company ;
        $headers = 'From:';

        // admin email
        $message  = "A new user has been created"."\r\n\r\n";
        $message .= 'Name: ' .$first_name."\r\n";
        $message .= 'Company: '.$company."\r\n";
        $message .= 'Email: '.$userEmail."\r\n";
        @wp_mail( get_option( 'admin_email' ), $subject, $message, $headers );

        // remove html content type
        remove_filter ( 'wp_mail_content_type', 'wpmail_content_type' );
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire