advanced_form()
advanced_form( $form_key_or_id, $args = [] )
Renders a form by a form key or form post ID. For example:
advanced_form( 'form_62bd15508b9c9' );
// or
advanced_form( 123 );
For a list of available arguments, see Display arguments.
af_get_field()
$value = af_get_field( $field_key_or_name, $args = [] )
Gets the value of a desired field from the current form submission. For example:
$value = af_get_field( 'field_62bd15508b9c9' );
// or
$value = af_get_field( 'Name' );
The optional $args
array supports the following arguments:
fields
- An array of ACF field arrays to search for the desired field. Defaults to all fields in the current submission.formatted
- Whether to return the formatted value or the raw value. Defaults totrue
.
af_save_field()
af_save_field( $field_key_or_name, $object_id )
Saves the value of a submitted field directly to an object (post, user, term). The $object_id
can be any format
supported by ACF's core acf_decode_post_id()
function (See GitHub).
Some common examples include:
$post_id
- To save to a post.$taxonomy . '_' . $term_id
- To save to a term in a specific taxonomy.'term_' . $term_id
- To save to a term.'user_' . $user_id
- To save to a user.'option'
- To save to the options table.
af_save_all_fields()
af_save_all_fields( $object_id, $excluded_fields = [] )
Saves all submitted fields directly to an object (post, user, term). The $object_id
is as
per af_save_field().
af_register_form()
af_register_form( $form )
Registers a form via PHP for use with the advanced_form()
function. You may use this to create forms without using the
UI. See Registering forms programmatically for more information.
af_get_form()
$form = af_get_form( $form_key_or_id )
Gets a form array by a form key or form post ID. For example:
$form = af_get_form( 'form_62bd15508b9c9' );
// or
//$form = af_get_form( 123 );
af_get_forms()
$forms = af_get_forms()
Gets an array of all registered forms.