***************
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 );
}
**********************************
Thank You, Elliot!
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
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!
Great video about using ACF to power custom WordPress site builds 🙌 https://t.co/ZX7n1glzxt
— Advanced Custom Fields (@wp_acf) January 11, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.