Support

Account

Home Forums Front-end Issues acf_form without loggin in Reply To: acf_form without loggin in

  • Hello John,

    Actually yes, we have that.
    I even tried to take a clean code now, from the link you sent, and added post_author, but even that does not seem to work, we keep getting returned to the form when not logged in

    function my_pre_save_post( $post_id ) {
    
        // check if this is to be a new post
        if( $post_id != 'new' ) {
    
            return $post_id;
    
        }
    
        // Create a new post
        $post = array(
            'post_status'  => 'draft' ,
            'post_author' => '9',
            'post_title'  => 'A title, maybe a dadadada variable' ,
            'post_type'  => 'hufter' ,
        );  
    
        // insert the post
        $post_id = wp_insert_post( $post ); 
    
        // return the new ID
        return $post_id;
    
    }
    
    add_filter('acf/pre_save_post' , 'my_pre_save_post', 10, 1 );