• Resolved Imran Siddiq

    (@flickimp)


    We’ve enabled the ‘Admin Approval’ required before a Post submitted by the form is published – but is there a way to send an email to specific emails when the form is submitted?

    So they know there is a post that needs to be checked.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Shabti Kaplan

    (@shabti)

    @flickimp

    Hey Imran, you can definitely send email notifications when the form is submitted. With the pro version, there are settings for this in the form builder, but I am writing up a code snippet for you to do this with the free version

    Plugin Author Shabti Kaplan

    (@shabti)

    Here is the code snipppet that will notify you when a form is submitted:
    Make sure to update to 3.13.3 as we just added this hook. Don’t forget to change the email addresses that are hardcoded in

    add_action('frontend_admin/form/after_submit', 'my_frontend_submit_form', 10, 1);
    function my_frontend_submit_form( $form ) {
        
        $submission_id = $form['submission'];
        $approve_url = admin_url( "admin.php?page=fea-settings-submissions&action=edit&id=$submission_id" );
        //get important fields
        $email_title = 'New form submission on your site: ' . esc_html( $form['submission_title'] );
        $email_content = 'A new post is awaiting your approval. <a href="'.esc_url( $approve_url ).'">Click here</a> to approve.';
        $email_address = '[email protected], [email protected]';
        
        if( $email_address ) {
            $email_sent = wp_mail( $email_address, $email_title, $email_content );
        }
    }
    Thread Starter Imran Siddiq

    (@flickimp)

    Big thanks, but there was an error;
    syntax error, unexpected ‘;’, expecting ‘)’ on line 8

    Plugin Author Shabti Kaplan

    (@shabti)

    Sorry to hear that. I improved the code so it’s easier to read and troubleshoot. You can also add localization if you need.

    add_action('frontend_admin/form/after_submit', 'my_frontend_submit_form', 10, 1);
    function my_frontend_submit_form( $form ) {
        
        $submission_id = $form['submission'];
    
        $approve_url = admin_url( "admin.php?page=fea-settings-submissions&action=edit&id=$submission_id" );
    
        $email_title = sprintf( __( 'New form submission on your site: %s' , 'namespace' ), $form['record']['submission_title'] );
    
        $email_content = sprintf( __( 'A new post is awaiting your approval. <a href="%s">Click here</a> to approve.', 'namespace' ), $approve_url );
    
        $email_address = '[email protected], [email protected]';
        
        if( $email_address ) {
            $email_sent = wp_mail( $email_address, $email_title, $email_content );
        }
    }
    Plugin Author Shabti Kaplan

    (@shabti)

    @flickimp

    Hey Imran. I’ll mark this as resolved, but if you have any more questions, I’m here for you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Notify Emails’ is closed to new replies.