Site admin email address in contact form

Hi,

I am using the jetpack contact form in a multisite setup. If a user creates his own site (registers to be site admin) I want his email address to be automatically included to be one of the reciepients of this contact form. Is there a shortcode or similar I can use for this?

Thank you very much.

  • Vaughan
    • Ex Staff

    Hi rico,

    Hope you’re well?

    There isn’t a way of achieving this from within the plugin itself, but we could perhaps use a filter for this.

    <?php
    add_filter( 'contact_form_to', 'wpmu_jcf_custom_emails', 999 );
    function wpmu_jcf_custom_emails($to) {
    $emails = array();
    $sites = get_sites();
    foreach ( $sites as $site ) {
    switch_to_blog( $site->blog_id );
    $emails[] = get_option('admin_email');
    restore_current_blog();
    }

    return $emails;
    }

    I haven’t tested the above, but hopefully now the contact form submissions should now be sent to all site admin emails (as defined in dashboard > general)

    Simply create a file called jetpack-custom-emails.php

    Then place the above code in this file (make sure that <?php is on the very first line with no spaces before it.

    Then upload this file to /wp-content/mu-plugins

    Hope this helps