Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Continued: ACF and front-end posting WordPress

Please see the history of this questions here: http://wpquestions.com/question/showChronoLoggedIn/id/8188 . I thought I had solved it so I rewarded the award, but it turns out I need some more help.

The function I created works fine to add posts but it seems when I try to update posts it just re-populates the same data as the first publish.

Here is my current function:
//Save ACF field as post_content for front-end
add_action('acf/save_post', 'change_content_frontend');
function change_content_frontend($post_id) {
if(get_post_type( $post_id ) != 'acf'){ //This function won't run if adding/updated fields/field-groups in wp-admin
$post_content = get_post_meta($post_id,'user_post_content',true);
$post_title = get_post_meta($post_id, 'user_post_title' , true);
$post_slug = sanitize_title_with_dashes ($post_title,'','save');
$post_slugsan = sanitize_title($post_slug);
$my_post = array();
$my_post['ID'] = $post_id;
$my_post['post_content'] = $post_content;
$my_post['post_title'] = $post_title;
$my_post['post_name'] = $post_slugsan;
remove_action('acf/save_post', 'change_content_frontend');
wp_update_post( $my_post );
add_action('acf/save_post', 'change_content_frontend');
}
}

Answers (1)

2013-03-25

Arnav Joy answers:

can you describe in full what is the problem ?