Skip to content

Instantly share code, notes, and snippets.

@thefuxia
Created August 29, 2012 23:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thefuxia/3520629 to your computer and use it in GitHub Desktop.
Save thefuxia/3520629 to your computer and use it in GitHub Desktop.
T5 Filter System From Mail
<?php # -*- coding: utf-8 -*-
/*
* Plugin Name: T5 Filter System From Mail
* Description: Sets the WP from mail address to the first admin’s mail and the from name to blog name.
* Plugin URI: http://toscho.de/?p=2201
* Version: 2012.08.30
* Author: Thomas Scholz
* Author URI: http://toscho.de
* License: MIT
*/
if ( ! function_exists( 't5_filter_system_from_mail' ) )
{
/**
* First admin's e-mail address or blog name depending on current filter.
*
* See wp-includes/pluggable.php::wp_mail()
*
* @param $input Name or email address
* @return string
*/
function t5_filter_system_from_mail( $input )
{
if ( 0 !== stripos( $input, 'wordpress' ) )
{
return $input; // Not auto-generated
}
return get_option( 'wp_mail_from' == current_filter()
? 'admin_email' : 'blogname' );
}
add_filter( 'wp_mail_from', 't5_filter_system_from_mail' );
add_filter( 'wp_mail_from_name', 't5_filter_system_from_mail' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment