Support

Account

Home Forums ACF PRO Validate Value en post front end

Solved

Validate Value en post front end

  • Hi,

    I’ve a little issue with a simple front end form.

    I have a form to create, on front end, new post (for my members).
    I just want to check is Title and content are not empty.

    But the submit don’t check my validate value filter.

     acf_form(array(
       ‘post_id’ => ‘new_post’, 
       ‘post_title’ => true,
       ‘post_content’ => true,
       ‘new_post’ => array(
           ‘post_type’ => ‘post’, 
           ‘post_status’ => ‘draft’
        ),
        ‘updated_message’ => "ok", 
        ‘submit_value’ => "Valider l’article"
    ));

    And my check in functions.php :

    add_filter('acf/validate_value/key=editor-xxx', 'user_post_valid_acf', 10, 1);
    
    function user_post_valid_acf(){
    	if(!empty($_POST['editor-xxx'])){
    return true;
    }else{
    return false;
    }
    }

    Regards

  • I’ve looked into this and as far as I can see there isn’t any way to make ACF validate that there is content in either post title or the post content when they are included on a front end form.

    In order to do this you would need to create an ACF field for the title and/or the content for you front end form make these fields required. Then you’d need to create an acf/save_post filter to update the post title, post content and post slug fields.

  • Thanks for your answer !

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.