@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
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 );
}
}
Big thanks, but there was an error;
syntax error, unexpected ‘;’, expecting ‘)’ on line 8
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 );
}
}
@flickimp
Hey Imran. I’ll mark this as resolved, but if you have any more questions, I’m here for you.