• Hey

    Nice plugin, thanks.

    I made a small change you might like to incorporate, I’m only changing the email “from” field when it is still the WordPress default. i.e. with the plugin as-is, I expect settings added to WooCommerce won’t take effect.

    function get_from_email( $email ) {
        // If it's already been changed by another plugin, return here.
        if ( 0 !== strpos( $email, 'wordpress@' ) ) {
            return $email;
        }
    
        $options = get_option( 'wp_from_email' );
        if ( $options && ! empty( $options['email'] ) ) {
            return $options['email'];
        }
        else {
            return $email;
        }
    }
    
    function get_from_name( $name ) {
        // If it's already been changed by another plugin, return here.
        if( 'WordPress' !== $name ) {
            return $name;
        }
    
        $options = get_option( 'wp_from_email' );
        if ( $options && ! empty( $options['name'] ) ) {
            return $options['name'];
        }
        else {
            return $name;
        }
    }
  • The topic ‘Conditionally change email’ is closed to new replies.