HelpersFREE

Docs Hooks & Helpers Helpers

#Add Validation Error

This function is a cousin of the native acf_add_validation_error() helper, but instead of using field key attribute, the field name or field key can be used as selector. It can be used within acf/validate_save_post & acfe/validate_save_post hooks.

Just like its cousin, it is possible to leave the selector field empty to throw a general error.

/*
 * ACFE Add Validation Error
 * 
 * @param  string  $selector Field name, key or empty (global error)
 * @param  string  $message  Message to render
 */
acfe_add_validation_error([$selector = ''], [$message = ''])
acfe_add_validation_error('my_field', 'Field Custom error message');
acfe_add_validation_error('', 'Global Custom error message');

#Get Fields

This function is a cousin of the native get_fields() helper, but instead of returning top level fields name, it will return field keys to produce an array comparable to the $_POST['acf'] array returned during a post save.

This function is useful when dealing with advanced hooks like acf/pre_load_value.

/*
 * ACFE Get Fields
 * 
 * @param   string  $post_id       ACF Post ID
 * @param   bool    $format_value  Whenever to format values or not
 * @return  array
 */
acfe_get_fields($post_id, [$format_value = false])
$values = acfe_get_fields(12);

#Get Field Group From Field

This helper allows developer to retrieve the Field Group object from any field or sub field.

/*
 * ACFE Get Field Group From Field
 * 
 * @param   array  $field  Field Array
 * @return  array
 */
acfe_get_field_group_from_field($field)
$field = acf_get_field('my_field');
$field_group = acfe_get_field_group_from_field($field);

#Get Post ID

This helper is an universal function allowing to retrieve the current ACF Post ID in the back-end and front-end. It can be used in hooks where the post_id is not available, like acf/load_field or acf/render_field.

/*
 * ACFE Get Post ID
 * 
 * @return  string  Current ACF Post ID
 */
acfe_get_post_id()

#Get Setting

This function is a cousin of the native acf_get_setting() helper. It will simply prefix any setting name with acfe/ to target ACF Extended specific settings.

It is recommended to use this function in the acfe/init hook to avoid any undefined function error if the developer disable the ACF Extended plugin.

/*
 * ACFE Get Setting
 * 
 * @param   string  $name   ACFE setting name
 * @param   string  $value  Default value
 * @return  mixed
 */
acfe_get_setting($name, [$value = null])

#Update Setting

This function is a cousin of the native acf_update_setting() helper. It will simply prefix any setting name with acfe/ to target ACF Extended specific settings.

It is recommended to use this function in the acfe/init hook to avoid any undefined function error if the developer disable the ACF Extended plugin.

/*
 * ACFE Update Setting
 * 
 * @param   string  $name   ACFE setting name
 * @param   string  $value  Value
 */
acfe_update_setting($name, $value)

#Is Admin

This helper allows developers to check if the current context is executed in the WordPress back-end. It can be used in hooks like acf/load_field or acf/render_field.

Note that this function will also make the difference from ajax request made in the back-end and the front-end (when using ACF Form or ACFE Form).

/*
 * ACFE Is Admin
 * 
 * @return  bool
 */
acfe_is_admin()

#Is Front

This helper allows developers to check if the current context is executed in the WordPress front-end. It can be used in hooks like acf/load_field or acf/render_field.

Note that this function will also make the difference from ajax request made in the back-end and the front-end (when using ACF Form or ACFE Form).

/*
 * ACFE Is Front
 * 
 * @return  bool
 */
acfe_is_front()

#Is Admin Screen

This helper allows developers to check if the current context is executed in ACF Admin Screens (Field Groups UI, Tools etc..). It is possible to include ACF Extended modules like Dynamic Post Types, Taxonomies, Forms etc…

/*
 * ACFE Is Admin Screen
 * 
 * @param   bool  $modules  Whenever to include ACFE modules or not
 * @return  bool
 */
acfe_is_admin_screen([$modules = false])

#Is Dynamic Preview

This helper allows developers to check if the current context is executed in the Flexible Content Preview Mode or ACF Block Type Preview.

/*
 * ACFE Is Dynamic Preview
 * 
 * @return  bool
 */
acfe_is_dynamic_preview()