rwmb_frontend_validate and update $_POST value

Support MB Frontend Submission rwmb_frontend_validate and update $_POST valueResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #44793
    Nicholas CoxNicholas Cox
    Participant

    Hi

    When i validate a form using 'rwmb_frontend_validate' is there a way to update/set a $_POST value? Im askign as i have a hidden field which i would like to check is correct and if not then updtae the field value

    thanks

    Nick

    #44804
    PeterPeter
    Moderator

    Hello Nick,

    Yes, you can update the $_POST value when validating the form. For example:

    add_filter( 'rwmb_frontend_validate', function( $validate, $config ) {
    	$_POST['field_id'] = 'test field value';
    	rwmb_request()->set_post_data( $_POST );
    
        return $validate;
    }, 10, 2 );

    Following the documentation https://docs.metabox.io/actions/rwmb-before-save-post/

    #44807
    Nicholas CoxNicholas Cox
    Participant

    Hi Peter,

    that worked great, could not find that in the docs.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.