Forums

Contact Form 7
From Email/Name in emails with ContactForm7, WP-members & edit in funct (5 posts)

  1. lauravk
    Member
    Posted 4 months ago #

    Hi there!

    I'm using two plugins which I both love and need for my website. It is Contact Form 7 and WP Members.

    Contact Form 7 is used for a variety of (contact)forms on my website.

    WP Members controls the subscription from my users. When a registration email is sent, it was send with wordpress@mydomain.com and the name WordPress. Because I obviously didn't think this looked pretty, I made a changed to my theme functions.php:

    add_filter( 'wp_mail_from', 'my_mail_from' );
    function my_mail_from( $email )
    {
    return 'myemail@mydomain.com';
    }

    add_filter( 'wp_mail_from_name', 'my_mail_from_name' );
    function my_mail_from_name( $name )
    {
    return 'My Name is displayed here now';
    }

    (as described here: http://butlerblog.com/2011/07/08/changing-the-wp_mail-from-address-in-wordpress-without-a-plugin/ )

    BUT...

    When since this edit, when I'm now receiving an email from a client using the Contact Form 7, it always is sent with the from email/name I've set up in the functions.php. This is obviously not practical since I can't find any emails back and it's not easy for an reply.

    I was wondering if there was a way/hack/fix so WP will still sent registrations with the right from email/name, but I will also receive emails via the contact form with the right email/name from the sender.

    Maybe a fixup in de Contact Form plugin files? Or maybe in the WP Members plugin files?

    I really hope someone can help me!

    http://wordpress.org/extend/plugins/contact-form-7/

  2. Chad Butler
    Member
    Posted 4 months ago #

    WP-Members has a process for pluggable functions. All of the emails to the user are generated in wpmem_inc_regemail found in wp-members-email.php. This is a pluggable function.

    You could try setting up a plugged version of the function following the process outlined here and adding the filter calls in there at some point before it fires wp_mail. That would isolate the filter to only be used when the wpmem_inc_regemail function is used.

  3. lauravk
    Member
    Posted 4 months ago #

    Hi Chad, thanks for your reply!
    I will take a closer look at it soon!

  4. Chad Butler
    Member
    Posted 4 months ago #

    An update to this...

    The 2.7.0 version added the ability to put values for this filter in via the plugin's admin panel. However, this does effect anything that uses wp_mail (just like using a filter in functions.php).

    Based on what you described above, I thought about it and came to the conclusion that it would be better to move these filters into the WP-Members email functions so these addresses (if set - they are optional) only are used by the plugin. That way, we keep it kind of self contained. This change is being added to the upcoming 2.7.1 release.

    If someone wants to have a sitewide filter, they can still do that via an add to functions.php, but if they need something for just the plugin, they can set it in the admin panel. (Hope that makes sense...)

  5. lauravk
    Member
    Posted 4 months ago #

    Hi Chad,
    thank you so much! I'm looking forward to the 2.7.1 release! I agree that this idea makes sense, since I have no trouble adding the code to the functions.php but think it's very difficult to edit the WP-members plugin (especially since I would loose it everytime I update) :)

Reply

You must log in to post.

About this Plugin

About this Topic