Pozdrav ekipa,
imam jedan problem s ACF pluginom. Pokušavam napraviti da logirani korisnik s frontend-a može popuniti custom post type. Uspio sam s njihove dokumentacije dobiti formu, ali ne mogu nikako otkriti zašto mi ne radi submit button za tu formu. Ima netko iskustva s popunjavanjem custom post type s front formom?
Ovaj kod koristim u functions.php
function my_pre_save_post( $post_id ) {
// bail early if not a new post
if( $post_id !== 'new_post' ) {
return $post_id;
}
// vars
$title = $_POST['fields']['field_5ad448800c46d'];
// Create a new post
$post = array(
'post_status' => 'publish',
'post_type' => 'sjecanje',
'post_title' => $title,
);
// 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' );
ovaj na page-create.php
<?php acf_form(array(
'field_groups' => array('43'), // Field Group name
'post_id' => 'new_post',
'new_post' => array(
'post_type' => 'sjecanje',
'post_status' => 'publish'
),
'submit_value' => 'Objavi'
)); ?>