• Resolved Afterword

    (@ahateleybrowne)


    Hi,

    I’m wanting to pass an email from a page into a contact form using the email/recipient filter. I’m quite certain it used to work, but it does not appear to be sending them through. It lodges the entries, and my website has no problem issuing emails. I’m stumped.

    function staff_MemberEmail( $recipient, $email, $form, $fields ) {
    	
        // Get Staff ID
        $url = parse_url($_SERVER['REQUEST_URI']);
        $staffID = substr($url[query], strpos($url[query], '=' ) + 1);
        
        // Query email address
        $args = array(
            'post_type' => 'staff',
            'p' => $staffID,
        );
    
        $staff = new WP_Query( $args );
    
        if ( $staff-> have_posts() ) :
    
            while ( $staff-> have_posts() ) : $staff-> the_post();
                
                $email = trim(get_field('email'));
                $recipient .= ', ' . $email;
                
            endwhile;
    
        endif;
        
        return $recipient;
        
    }
    
    add_filter( 'af/form/email/recipient/id=form_ID', 'staff_MemberEmail', 10, 4 );

    Any ideas as to why this wouldn’t work?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Sending form to email address’ is closed to new replies.