receive notifications
Support › MB Frontend Submission › receive notifications
- This topic has 6 replies, 2 voices, and was last updated 2 years ago by
Peter.
-
AuthorPosts
-
October 20, 2023 at 8:36 PM #43568
369cycle
ParticipantUsing mb frontend submission, how to set up email in shortcode to receive notifications of new articles published?
October 20, 2023 at 9:25 PM #43569369cycle
Participantadd_action( 'rwmb_frontend_after_process', function( $config, $post_id ) { if ( 'my-meta-box' === $config['id'] ) { wp_mail( '[email protected]', 'New submission', 'A new post has been just submitted.' ); wp_safe_redirect( 'thank-you' ); die; } }, 10, 2 ); do_action( 'rwmb_frontend_after_process', 'date_now', 75 );October 20, 2023 at 9:27 PM #43570369cycle
ParticipantOctober 21, 2023 at 11:50 AM #43576Peter
ModeratorHello,
There is a parameter
rwmb_frontend_field_post_idin the URL when you edit a post. Then you can use the code below to check if it is a new post submitted (not an edited post):add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) { if( empty( $_GET['rwmb_frontend_field_post_id'] ) ) { // your code to send email goes here } }, 20, 2 );October 21, 2023 at 2:18 PM #43578369cycle
Participant01.How can I have this function for a specific form, or can I send it to different mailboxes for different forms?
02.In addition, the letter was successfully sent to "Chinese" instead of "English"!
add_filter( 'rwmb_frontend_field_value_post_id', 'my_custom_population_function', 10, 2 ); function my_custom_population_function( $value, $args ) { if ( $args['id'] === 'date_now' ) { // Only filter for a specific form. $value = 123; } return $value; } add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) { if( !empty( $_GET['rwmb_frontend_field_post_id'] ) ) { wp_mail( '[email protected]','New submission', 'A new post has been just submitted.'); wp_safe_redirect( 'thank-you' ); die; } }, 20, 2 );October 21, 2023 at 10:02 PM #43581369cycle
Participant03.If there is an email address set on the form to fill in, how can this email also receive the email after filling in the form?
October 23, 2023 at 9:37 PM #43590Peter
ModeratorHello,
1. You can combine your code in the second comment (https://support.metabox.io/topic/receive-notifications/?swcfpc=1#post-43569) to check the specific form by form ID and send the email.
2. I'm not sure if a third-party plugin can cause this issue but the send function works as it is. It isn't a Meta Box issue itself.
3. You can get the field email value via the $_POST variable. For example:
wp_mail( $_POST['custom_field_id'],'New submission', 'A new post has been just submitted.'); -
AuthorPosts
- You must be logged in to reply to this topic.