redirect only on submit - not an update

Support MB Frontend Submission redirect only on submit - not an updateResolved

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

    Hello,

    Thank you very for the "redirect" attribute In MB Frontend submission.

    However, I'm looking for the option for the redirect only on new post submission, not an edit (update) the posts.

    I have checked the https://docs.metabox.io/extensions/mb-frontend-submission/#general-hooks. But I'm not a superuser to modify the code for the customization.

    #32036
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can check the post ID in the URL if the users edit the post from the frontend dashboard. Here is the example code

    add_filter( 'rwmb_frontend_redirect', function( $redirect, $config ) {
        // Get the post ID from the URL if the user edit the post from frontend dashboard
        $value = $_GET['rwmb_frontend_field_post_id'];
        if ( empty( $value ) ) {
            $redirect = 'https://yourdomain.com/custom-page/';
        }
        return $redirect;
    }, 10, 2 );
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.