Home › Forums › General Issues › front end creat post
Hello , again and again thanks for the great plugin more digging more in love with it here what is going on
i had follow
http://www.advancedcustomfields.com/resources/tutorials/using-acf_form-to-create-a-new-post/
but
if( $post_id != 'new' )
{
return $post_id
}
case a server error
any way i delete it and it’s work but allows when i enter this page where the form load()
the fields allows with the last post information not empty why it’s casing this and how to fix it thanks
Hello Elliot thanks for the replay here what’s going on in function.php
when
/* if( $post_id != 'new' )
{
return $post_id;
}*/
is active i mean without the /* the form not saving but with it active it’s not saving but i think the $post id is important for the next function which it’s for the post_title which it’s also not working
add_action('save_post', 'modify_post_title');
function modify_post_title($post_id) {
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
return;
if ( ! wp_is_post_publish( $post_id ) ) {
if('taxirent' == get_post_type($post_id) ) {
$post_title = the_field('munf', $post_id) .' : '. the_field('price', $post_id);
}
}
if('acf' != get_post_type($post_id)) {
if ($post_title == '') { $post_title = $_POST['post_title'];}
remove_action('save_post', 'modify_post_title');
$arg = array();
$arg['ID'] = $post_id;
$arg['post_title'] = $post_title;
wp_update_post( $arg );
add_action('save_post', 'modify_post_title');
}
}
and when load page which it’s content the form
<?php
/*
Template Name: Add Ads
*/
?>
<?php
acf_form_head();
get_header();
?>
<?php get_sidebar('top'); ?>
<?php
if ( is_user_logged_in() ) {
$args = array(
'post_id' => '!new',
'field_groups' => array(153),
);
acf_form( $args );
} else {
echo 'вы не можете получить доступ к этой странице';
}
?>
<?php get_sidebar('bottom'); ?>
<?php get_footer(); ?>
the form fields are not empty i mean it’s not giving a new post id what i am missing
Hi @5vlast
Looks like your if statement:
if( $post_id != 'new' )
{
return $post_id;
}
will fail becuase your post_id is never going to be ‘new’, it will always be ‘!new’.
I believe some debugging is needed to figure out the issue and get it working. Debug line by line and ask yourself why it isn’t working.
Good luck!
The topic ‘front end creat post’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.