Support

Account

Forum Replies Created

  • ***************
    The following function should be able to help you get the value and assign it to the post
    function get_acf_title( $post_id ){
    $title = get_field( ‘title’, $post_id );

    if( empty( $title ) ){
    $title = get_the_title( $post_id );
    }

    if( $title == ‘-‘ ){
    $title = ”;
    }

    return apply_filters( ‘the_title’, $title );
    }
    **********************************

  • Hi,guys!
    Solution for ACF PRO 5

    To concatinate strings, you do so like this:
    $string = 'foo' . 'bar';
    
    So ACF $_POST data would look like:
    'post_title' => $_POST['acf']['field_5481ab2cdda13'] . ' ' . $_POST['acf']['field_5481ab2cdda14'],
  • It works? Uhhh. Post here the example of code,plz.

  • Text fields from front end form, Ben.
    How do I combine multiple fields in the title? What is the syntax for concatenate?
    ‘post_title’ => $_POST[‘acf’][‘field_5481ab2cdda13’] [‘field_54814faa2f090’], //NOT work
    For example of title- NAME+CITY+DATE –> DMITRY::MOSCOW::22.11.2014 (:: – separator).

    Help me, plz

    My front-end form –

    <?php 
    /**
     * Template Name: Page with ACF form
     */
    acf_form_head();
    get_header(); 
    the_post(); 
    ?>
    	<div id="primary">
    		<div id="content" role="main">
    			<?php 
    			$args = array(
    				'post_id' => 'new',
    				'field_groups' => array( 5 ),
    				'updated_message'	=> 'Up the post!'
    			);
    			acf_form( $args ); 
    			?>
    
     ?>
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Plugin –

     
    /**
    * ACF Frontend Form
    */
    
    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'  => 'publish' ,
            'post_title'  => $_POST['acf']['field_5481ab2cdda13'],
            'post_type'  => 'testimonials' ,
            'post_category'=>array(4),
        );  
    
        // insert the post
        $post_id = wp_insert_post( $post ); 
    
        // update $_POST['return']
        $_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );    
    
        // return the new ID
        return $post_id;
    }
    
    add_filter('acf/pre_save_post' , 'my_pre_save_post' );
  • Hi guys! How do I combine multiple fields in the title? What is the syntax for concatenate?
    ‘post_title’ => $_POST[‘acf’][‘field_5481ab2cdda13’] [‘field_54814faa2f090’], //NOT work

    VER 5 PRO

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