I know you can use acf_form
for displaying the generic post form in the front end of a WordPress site. Can I use it or something similar to display an options page in the front end?
I’m working on a system where the wp-admin
section will not be visible to anyone except the administration, but options pages should be available to editors and other lower roles in the frontend.
I’m using ACFPRO as a theme included plugin. Latest WP installed.
Right now I’ve got the following working:
acf_local()->get_field_groups()
.acf_get_local_fields( $fieldgroup_key )
.foreach ( $groups as $fields ) : foreach ( $fields as $field_key => $field_data ) : printf( ... ); endforeach; endforeach;
action=""
).update_field( $field_key, $value, 'options' )
.Currently this works fine for non-JS infused fields, such as selects, text fields and so on. I’m working on getting the color picker working, which in the end should use a hidden text field anyway.
Is there a more correct way to do this or should I wrap this into a plugin of sorts?
Thanks for posting this. This is exactly what I’m looking for. Would you mind posting your entire form code? I’m having trouble following exactly what you did.
Thanks
I’m afraid I can’t find the exact code I used for my previous post. 🙁
Additionally I’m not sure whether the method of doing this has changed between ACF4 and ACFPRO.
This can be done using acf_form() http://www.advancedcustomfields.com/resources/acf_form/
Create the options page and the field groups you want on it and then for the front end form use options
as the post_id
value and list the field groups that you want to show.
$args = array(
'post_id' => 'options',
'field_groups' => array(3199) // this is the ID of the field group
);
acf_form($args);
Follow the rest of the instructions for using acf_form()
Sorry, ignore me – realise that you have to explicitly call the fields / field groups rather than the whole form…
>>>
Hi @hube2
I’m trying to do this but just nothing on the front end apart from my submit button.
Code:
<?php acf_form(array(
'post_id' => 'options',
'submit_value' => 'Update settings',
'return' => add_query_arg( 'updated', 'true', home_url() . '/settings' ),
)); ?>
Any idea?
cheers
Mike
This worked for me. Of course call ACF header correctly before
<?php acf_form(array(
'post_id' => 'options',
'post_title' => false,
'submit_value'=> 'Update',
'field_groups'=> [643],
)); ?>
use your field group ID-s
The topic ‘Options page in front-end’ is closed to new replies.
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.