• Resolved tommasogavioli

    (@tommasogavioli)


    Hi, i looked everywhere for a solution but i couldn’t find any. I hope i’m not repeating an exhisting topic.
    I have a form which can be filled only by registered users. I’d like to avoid to create a User email field because, in fact, user is already logged and he already gave his email.
    But without an email field the user doesn’t get any submission notification: just the in-page thank you message after sending the form.
    Is there a way to customise the recipient basically telling the plugin to send a notification to the wp user_email when he submits a form?
    I tried several ways (like {user:user_email} etc but nothing works out…

    Can anybody help me?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author fabianlindfors

    (@fabianlindfors)

    Hi!

    You can use the af/form/email/recipient" filter for this: https://advancedforms.github.io/filters/af-form-email-recipient/. You can get the current users email address withwp_get_current_user()->user_email`.

    Hope this helps!

    Thread Starter tommasogavioli

    (@tommasogavioli)

    Hi, thank you for the answer but i didn’t understand.

    Do i have to add something like that to my function php?

    <?php

    function filter_email_recipient( $recipient, $email, $form, $fields ) {
    // Add another recipient to email
    $recipient .= ‘, wp_get_current_user()->user_email’;

    return $recipient;
    }

    Thanks!

    Plugin Author fabianlindfors

    (@fabianlindfors)

    It’s close but should be something more like this:

    
    function filter_email_recipient( $recipient ) {
      $recipient = wp_get_current_user()->user_email;
      return $recipient;
    }
    add_filter( 'af/form/email/recipient/key=FORM_KEY', 'filter_email_recipient', 10, 1 );
    

    Replace FORM_KEY with your actual form key ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to: Logged WP User Email Notification’ is closed to new replies.