• Resolved originalpiratematerial

    (@originalpiratematerial)


    The form allows you to send an email to a custom email address or one of the form fields. Is it possible to send to the email of the current logged in user without using custom code?

Viewing 1 replies (of 1 total)
  • Plugin Author fabianlindfors

    (@fabianlindfors)

    Unfortunately you would have to write a tiny bit of code to achieve this, but it isn’t to hard. Something like this should work:

    
    function filter_email_recipient( $recipient ) {
        $user = wp_get_current_user();
    
        // Check if current user exists
        if ( $user->ID != 0 ) {
           return $user->user_email;
        }
    
        return $recipient;
    }
    add_filter( 'af/form/email/recipient/key=FORM_KEY', 'filter_email_recipient', 10, 1 );
    

    Replace FORM_KEY with your form key. ??

    Hope this helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Send email to current user’ is closed to new replies.