Support

Account

Home Forums General Issues front end creat post Reply To: front end creat post

  • 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