Support

Account

Forum Replies Created

  • Sorry @James, didn’t get to reply to this at the time. In the end we went with another solution, but I’ll be sure to revisit this solution in the future, when we need to build something similar. Many thanks for your reply!

  • Have also used templates in the past, but stumbled on this post when wanting to have a cleaner solution for a new project. Unfortunately I can’t get this to work for pages. I don’t translate custom field groups, they’re the same in all languages. But the location rule only works for the language that was active when selecting a page.

    I know this is an old post, but perhaps I’m missing something or the have been updates to ACF that means this doesn’t work any longer? Would be good if this was built into core ACF, seems quite logical that the system could convert which page/ID is being used.

  • Got this working. For the hidden field issue, we used a field from a different field group (that isn’t part of the frontend form) and used the html_after_fields function:

    <?php acf_form(array(
    	'post_id'		=> 'new_post',
    	'field_groups' => array( GROUP-ID ),
    	'new_post'		=> array(
    		'post_type'		=> 'reviews',
    		'post_status'		=> 'draft',
    	),
    	'submit_value'		=> 'Create a new review',
    	'updated_message'   => 'Thank you for the review!',
    	'html_after_fields' => '<input type="hidden" name="acf[field_KEY-FROM-ADMIN]" value="OUR-POST-VALUE"/>',
    )); ?>

    For the other issue with post_title, it seems to have been an issue with this form value (text field) not being available when the form saved the new post the standard way. So in functions.php, we have this:

    <?php
    function acf_review_before_save_post($post_id) {
    	if (empty($_POST['acf']))
    		return;
    	$_POST['acf']['_post_title'] = $_POST['acf']['field_KEY-FROM-ADMIN'];
    	return $post_id;
    }
    add_action('acf/pre_save_post', 'acf_review_before_save_post', -1); ?>
  • Aha, so it’s handled outside of ACF. But still it doesn’t stop the functionality – often I find plugins get in the way of many base functions.

    Thanks again for taking the time to reply!

  • Thanks a lot Hube2! That worked, I just needed to add the option-call and all is fine:

    printf(get_field('my-ACF-field-value', 'option'), get_the_title($post->post_parent));

    I thought ACF probably didn’t use %s and this wouldn’t be possible, but I’m happy I was wrong. Amazing plugin, I am continuously impressed the more I learn about it.

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