Form actions for many custom fields in frontend form

Support MB Frontend Submission Form actions for many custom fields in frontend formResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #34238
    Prabakaran ShankarPrabakaran Shankar
    Participant

    According to the description in the form actions https://docs.metabox.io/extensions/mb-frontend-submission/ I need to use the metabox name to verify the 'config['id']'.
    In my case, I have many metabox IDs coupled in a frontend form. In this scenario, how can I verify and process the form actions to send an email after submission?

    Please help me to use the code.
    Below are the details of the content.

    page id: 7896
    form shortcode:

    [mb_frontend_form id="job-post-title,taxonomies-1-job,job-details,job-meta-university-address" post_type="job" post_status="pending" submit_button="Submit" edit="true" ajax="true" confirmation="You have successfully submitted your job. Visit the dashboard to edit it if you wish. We will contact you soon." redirect="https://nviewscareer.com/account/jobs-submitted-dashboard/"]

    ref.

    add_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 );

    what to use for 'my-meta-box' in my case?

    Sorry for these silly questions...

    #34256
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can explode the variable $config['id'] to an array and check if a meta box id is available in this array. For example:

        $meta_box_id = 'job-post-title';
        $config_ids = explode( ',', $config['id'] );
        if( in_array( $meta_box_id, $config_ids ) ) {
            wp_mail( '[email protected]', 'New submission', 'A new post has been just submitted.' );
        } else {
            echo "Do something if false";
        }
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.