Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter coelmay

    (@coelmay)

    Originally, the add_filter was:

    add_filter( 'wp_mail_from', 'my_mail_from' );
    function my_mail_from( $email ) {
         return "[email protected]";
     }

    I have modified this to:

    add_filter( 'wp_mail_from', 'my_mail_from' );
    function my_mail_from( $email ) {
        if ( preg_match('#^wordpress\@#',$email)) {
          return "[email protected]";
        } else {
          return $email;
        }
    }

    and it works—when I do a ‘forgot password’ the email comes from [email protected] and when I fill in the contact form, the email comes from the email used to fill in the contact form.
    Not sure if this is the ‘perfect’ workaround, or not.

    Now I just need something like above to change the from name.

    Thread Starter coelmay

    (@coelmay)

    I have the plugin installed on two sites—one a working business site, the other a test site.

    On the production site, the theme is a customised ‘Avada’, and the following plugins are activated:
    ? Akismet
    ? All in One Webmaster
    ? Captcha
    ? Contact Form 7
    ? Custom Meta Widget
    ? Enhanced Media Library
    ? Facebook
    ? Fusion Core
    ? Google XML Sitemaps
    ? Jetpack by WordPress.com
    ? LayerSlider WP
    ? Revolution Slider
    ? Shortn.It
    ? Twitter
    ? User Role Editor
    ? WP Google Authenticator

    * ‘WP Change Default Email’ had been running, but has since been uninstalled. However, an add_filter has been added to functions.php to change the default email address.
    ** The site runs at www1.example.com rather than www.example.com. I have noted in both WordPress and Contact Form 7, allowance is made to strip www. from domain for email.

    On the test site, a default theme, with plugins:
    ? Ban Hammer
    ? Contact Form 7
    ? Custom Bulk Actions
    ? Google XML Sitemaps
    ? Media Library Assistant
    ? Shortn.It
    ? Twitter
    ? WPFront Notification Bar

    WAIT!!! STOP PRESS!!!

    I had noted ‘WP Change Default Email’ was doing things I didn’t want, hence why I changed to the add_filter. However, the add_filter is what is now stopping the sender email coming through.
    The is an issue as I need this filter (due in part because of the running www1. NOT www.)

    Any thoughts on a workaround? (Maybe simply modifying the source to look for www1. as well/instead of? Could this be done as a filter maybe?)

    Any help appreciated.

    Thread Starter coelmay

    (@coelmay)

    And I’ve now removed the else as is breaks pretty much everything.

    Thread Starter coelmay

    (@coelmay)

    Modified that to
    if ( $page_slug != '' && ($wpdb->get_var( 'SELECT ID FROM‘ . $wpdb->posts .’WHEREpost_name= "'.$page_slug.'"')) !== FALSE )

    Thread Starter coelmay

    (@coelmay)

    Yeah, makes sense.

    In shortn_it_get_matching_post_id I’ve added:

    `if ( preg_match(‘/^(index\.php)?\?p\=(.*)$/’, $the_short) ) {
    return substr($the_short, strpos($the_short, ‘?p=’)+3,strlen($the_short));
    }`

    after if( $the_short == '' ).

    In shortn_it_headers after the if I’ve added:

    `else {
    global $wpdb;
    $page_slug = trim($_SERVER[‘REQUEST_URI’], ‘/’);
    if ( ($wpdb->get_var( ‘SELECT ID FROM ' . $wpdb->posts .' WHERE post_name = “‘.$page_slug.'”‘)) !== FALSE ) {
    $permalink = home_url(‘/’) . $page_slug . ‘/’;
    if ( $permalink != $current_url ) {
    wp_redirect( $permalink );
    exit();
    }
    }
    }`

    May not be the prettiest code in the world, but it works for me.

    And into .htacces I’ve added

    `RewriteCond %{HTTP_HOST} ^exm\.pl$
    RewriteCond %{REQUEST_URI} ^/?$
    RewriteRule ^(.*)$ https://example.com/$1 [R,L]`

    to capture people browsing directly to exm.pl.

Viewing 5 replies - 1 through 5 (of 5 total)