• Resolved dcmouser

    (@dcmouser)


    I would love to be able to use some kind of tag in the mail configuration of a form in the TO field to be able to specify that the form submission email should get sent to whatever the currently configured site admin email is for the blog; something like [admin_email].

    This would be useful in two scenarios. First, so that if the site admin email is changed I don’t have to remember to go to every form and change the emails there.

    Second, when cloning sites in a multi-user blog so that the contact form is still valid when copied to new sites.

    Thoughts?

    • This topic was modified 7 years, 2 months ago by dcmouser.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter dcmouser

    (@dcmouser)

    Anyone?

    anonymized-15380454

    (@anonymized-15380454)

    Try this:

    add_filter( 'wpcf7_special_mail_tags', 'my_wpcf7_special_mail_tags', 10, 2 );
    function my_wpcf7_special_mail_tags( $value, $tag ) {
    	if ( 'admin_email' == $tag ) {
    		return get_option( 'admin_email' );
    	}
    
    	return $value;
    }

    You can add it to functions.php of your site’s theme.

    Thread Starter dcmouser

    (@dcmouser)

    That sounds like a great solution Sally, I will try it!
    Thank you.

    Thread Starter dcmouser

    (@dcmouser)

    A quick report — it seems to work, but contactform7 complains loudly and displays error indicators in a few places because the email address specified as a tag [whatever] is reported as a malformed email address.

    Thread Starter dcmouser

    (@dcmouser)

    I found the solution, following up on Sally’s initial suggestion there is a nice filter to check for email validity, wpcf7_is_email.
    A custom version of that lets me say that the special email tags are valid.
    Thanks again, Sally!

    anonymized-15380454

    (@anonymized-15380454)

    No problem. =)

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘use a tag to refer to site/blog admin email’ is closed to new replies.