### Getting Started with Hybrid Engine in Test-Drive Mode Source: https://www.acf-extended.com/features/modules/performance-mode/hybrid-engine Initial setup for the Hybrid Engine in Test-Drive Mode, enabling the UI for metabox display and setting the mode to 'test'. ```php add_action('acfe/init', 'my_acfe_modules'); function my_acfe_modules(){ acfe_update_setting('modules/performance', array( 'engine' => 'hybrid', // use hybrid engine 'ui' => true, // display metabox (dev mode should be enabled) 'mode' => 'test', // use test-drive mode )); } ``` -------------------------------- ### Getting Started: Ultra Engine in Test-Drive Mode Source: https://www.acf-extended.com/features/modules/performance-mode/ultra-engine Enables the Performance Mode with the Ultra Engine in 'test-drive' mode, including the UI for metabox display. This configuration is recommended for initial setup and testing. ```php add_action('acfe/init', 'my_acfe_modules'); function my_acfe_modules(){ acfe_update_setting('modules/performance', array( 'engine' => 'ultra', // use ultra engine (default) 'ui' => true, // display metabox (dev mode should be enabled) 'mode' => 'test', // use test-drive mode )); } ``` -------------------------------- ### Settings Modal Example Source: https://www.acf-extended.com/features/fields/flexible-content/modal-settings This shows the configuration modal for layouts, using a cloned field group. It includes examples of Switch and Select fields. ```php 0Layout Switch YesNo YesNo YesNo Select Choice 1Choice 2Choice 3 1Layout Switch YesNo YesNo YesNo Select Choice 1Choice 2Choice 3 ``` -------------------------------- ### Custom Redirect Action Prepare Example Source: https://www.acf-extended.com/features/modules/forms/actions/redirect Example of how to control the Redirect Action's preparation phase using the `acfe/form/prepare_redirect` hook. This example stops the redirect if the user is not logged in. ```php add_filter('acfe/form/prepare_redirect/form=my-form', 'my_redirect_prepare', 10, 2); function my_redirect_prepare($action, $form){ // if user isn't logged in // do not redirect if(!is_user_logged_in()){ return false; } // return normally return $action; } ``` -------------------------------- ### Dynamic Render File Path Example Source: https://www.acf-extended.com/features/fields/flexible-content/dynamic-render Example paths for template, CSS, and JavaScript files relative to the theme directory. These paths are used to specify custom files for each layout. ```text Settings path usage example: * [/wp-content/themes/my-theme/]layouts/hero/template.php * [/wp-content/themes/my-theme/]layouts/hero/style.css * [/wp-content/themes/my-theme/]layouts/hero/script.js ``` -------------------------------- ### Selection Modal Example Source: https://www.acf-extended.com/features/fields/flexible-content/modal-settings This illustrates the selection modal for adding layouts, presenting them in a grid system. It shows example layouts like Header, Hero, Cards, and Newsletter. ```php 0Header Text 0Hero Text 0Cards Text 0Newsletter Text ``` -------------------------------- ### Post Action: Custom Prepare Example Source: https://www.acf-extended.com/features/modules/forms/actions/post Example of a custom preparation function for the post action. This function checks if the user is logged in and returns false to stop the action if they are not. ```php add_filter('acfe/form/prepare_post/form=my-form', 'my_post_prepare', 10, 2); function my_post_prepare($action, $form){ // if user isn't logged in // do not create/update the post if(!is_user_logged_in()){ return false; } // return normally return $action; } ``` -------------------------------- ### Payment Field PRO Example Source: https://www.acf-extended.com/features/fields/payment Displays a payment field with options for Stripe and PayPal. Includes example cart items and payment method selections. ```html Field Group Cart * Product A - $29 * Product B - $49 Options * Option 1 - $9 * Option 2 - $19 Gateway * Credit Card * PayPal Credit Card 01234567890123456789 Select card brand (optional) Number Select card card brand (optional) ``` -------------------------------- ### Prepare Field Hook Example Source: https://www.acf-extended.com/features/hooks-helpers/inline-hooks This example demonstrates the `prepare_field` inline hook, a proxy for `acf/prepare_field`. It changes the field's label before it is prepared. ```php $field = array( 'label' => 'My Text', 'key' => 'field_my_text', 'name' => 'my_text', 'type' => 'text', 'callback' => array( 'prepare_field' => function($field){ $field['label'] = 'New Label'; return $field; } ) ); ``` -------------------------------- ### Option Action: Prepare Hook Example Source: https://www.acf-extended.com/features/modules/forms/actions/option This example shows how to use the 'acfe/form/prepare_option' filter to modify the action's behavior before submission. It demonstrates how to conditionally stop the action by returning false, for instance, if a user is not logged in. ```php /** * Option Action: Prepare * * @array $action Action settings array * @array $form Form settings array * * @return array|false */ filter('acfe/form/prepare_option', $action, $form); filter('acfe/form/prepare_option/form=my-form', $action, $form); filter('acfe/form/prepare_option/action=my-option', $action, $form); ``` ```php add_filter('acfe/form/prepare_option/form=my-form', 'my_option_prepare', 10, 2); function my_option_prepare($action, $form){ // if user isn't logged in // do not submit the action if(!is_user_logged_in()){ return false; } // return normally return $action; } ``` -------------------------------- ### User Submit Action Examples Source: https://www.acf-extended.com/features/modules/forms/actions/user These examples illustrate the use of the 'acfe/form/submit_user' action hook, which triggers after a user has been successfully created, updated, or logged in. You can target specific forms or actions. ```php /** * User Action: Submit * * @int $user_id Created/Updated/Logged user ID * @array $args User arguments * @array $form Form settings array * @array $action Action settings array */ action('acfe/form/submit_user', $user_id, $args, $form, $action); action('acfe/form/submit_user/form=my-form', $user_id, $args, $form, $action); action('acfe/form/submit_user/action=my-user', $user_id, $args, $form, $action); ``` -------------------------------- ### Ultra Engine Meta Structure Example Source: https://www.acf-extended.com/features/modules/performance-mode/ultra-engine Illustrates the meta structure used by the Ultra Engine, showing compressed metadata in a single row. ```php a:6:{s:9:"_my_field";s:19:"field_5ffd218f27704";s:8:"my_field";s:27:"Vestibulum ac diam sit amet";s:11:"_my_content";s:19:"field_5ffd218f27704";s:10:"my_content";s:26:"Curabitur placerat non leo";s:8:"_my_date";s:19:"field_5ffd27b80a8af";s:7:"my_date";s:8:"20210831";} ``` -------------------------------- ### ACFE Save User Role Example Source: https://www.acf-extended.com/features/hooks-helpers/save-post Example of a function hooked to 'acfe/save_user/role=editor' to handle editor user data before saving. ```php add_action('acfe/save_user/role=editor', 'my_acfe_save_editor', 10, 2); function my_acfe_save_editor($post_id, $object){ // Retrieve the user input from "my_field" field get_field('my_field'); // Retrieve "my_field" field value from DB get_field('my_field', $post_id); // Loop thru the user input from "my_repeater" field if(have_rows('my_repeater')): while(have_rows('my_repeater')): the_row(); get_sub_field('my_sub_field'); endwhile; endif; } ``` -------------------------------- ### General Usage Example for Inline Hooks Source: https://www.acf-extended.com/features/hooks-helpers/inline-hooks This snippet demonstrates the general usage of inline hooks within `acf_add_local_field_group()`. It includes examples for both `prepare_field` and `validate_value` hooks. ```php acf_add_local_field_group(array( 'key' => 'group_1', 'title' => 'My Group', 'fields' => array( array( 'label' => 'My Text', 'key' => 'field_my_text', 'name' => 'my_text', 'type' => 'text', 'callback' => array( /* * acf/prepare_field */ 'prepare_field' => function($field){ $field['label'] = 'Company'; return $field; }, /* * acf/validate_value */ 'validate_value' => function($valid, $value, $field, $input){ if(strpos($value, 'Old Company Name') !== false) return 'Please remove mention of "Old Company Name".'; return $valid; } ) ) ) )); ``` -------------------------------- ### Custom Action Prepare Hook Example Source: https://www.acf-extended.com/features/modules/forms/actions/custom This example shows how to use the 'acfe/form/prepare_my-action' filter to control the preparation phase of a custom action. It prevents the action from proceeding if the user is not logged in by returning false. ```php add_filter('acfe/form/prepare_my-action', 'my_form_prepare', 10, 2); function my_form_prepare($action, $form){ // if user isn't logged in // do not submit the action if(!is_user_logged_in()){ return false; } // return normally return $action; } ``` -------------------------------- ### PayPal API Credentials Setup Source: https://www.acf-extended.com/features/fields/payment Lists the required PayPal API credentials (Username, Password, Signature, Merchant ID) for integration. ```text Key Name| Format ---|--- API Username| `xxxxxxxxx.domain.com` API Password| `xxxxxxxxxxxxxxxxxxxx` API Signature| `xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx` Merchant ID| `xxxxxxxxxxxxx` ``` -------------------------------- ### Custom E-mail Preparation Function Source: https://www.acf-extended.com/features/modules/forms/actions/e-mail Example of a custom PHP function to prepare the email action. This example stops the email from being sent if the user is not logged in. ```php add_filter('acfe/form/prepare_email/form=my-form', 'my_email_prepare', 10, 2); function my_email_prepare($action, $form){ // if user isn't logged in // do not send the e-mail if(!is_user_logged_in()){ return false; } // return normally return $action; } ``` -------------------------------- ### Edit Modal Example Source: https://www.acf-extended.com/features/fields/flexible-content/modal-settings This demonstrates the structure for editing layouts within a modal. It shows how to add and configure layout rows. ```php 0Layout Text 1Layout Text ``` -------------------------------- ### Global Validate Save Hook Examples Source: https://www.acf-extended.com/features/hooks-helpers/validate-save-post Demonstrates how to hook into the global 'acfe/validate_save' action to validate any object type (Post, User, Term, Options Page, Comment). Includes examples for targeting specific IDs. ```php /* * ACFE Validate Save * * @string $post_id 12 | term_46 | user_22 | my-options | comment_89 * @object/array $object The corresponding WP Object (Post, Term, User, Options Page or Comment) */ action('acfe/validate_save', $post_id, $object); action('acfe/validate_save/id=12', $post_id, $object); action('acfe/validate_save/id=term_46', $post_id, $object); action('acfe/validate_save/id=user_22', $post_id, $object); action('acfe/validate_save/id=my-options', $post_id, $object); action('acfe/validate_save/id=comment_89', $post_id, $object); ``` ```php add_action('acfe/validate_save', 'my_acfe_validate_save', 10, 2); function my_acfe_validate_save($post_id, $object){ // Retrieve the user input from "my_field" field get_field('my_field'); // Retrieve "my_field" field value from DB get_field('my_field', $post_id); // Loop thru the user input from "my_repeater" field if(have_rows('my_repeater')): while(have_rows('my_repeater')): the_row(); get_sub_field('my_sub_field'); endwhile; endif; // Add a custom validation error acfe_add_validation_error('my_field', 'This is a custom error'); } ``` -------------------------------- ### Menu Locations Field Render Examples Source: https://www.acf-extended.com/features/fields/menu-locations Displays the Menu Locations field in different formats: radio buttons, checkboxes, and a select dropdown. These examples show how the field can be presented to the user for selection. ```html Field Group Menu Locations * Primary Menu * Secondary Menu * Main Menu ``` ```html Menu Locations * Primary Menu * Secondary Menu * Main Menu ``` ```html Menu Locations Primary MenuSecondary MenuMain Menu ``` ```html Menu Locations Main MenuPrimary MenuSecondary Menu ``` ```html * ×Primary Menu * ×Secondary Menu * ``` -------------------------------- ### Checkbox Field Group Example Source: https://www.acf-extended.com/features/fields/checkbox Demonstrates the structure of a Checkbox field with simple choices. ```markdown Field Group Checkbox * **Label 1** value1 * **Label 2** value2 * **Label 3** value3 ``` -------------------------------- ### Stripe API Keys Setup Source: https://www.acf-extended.com/features/fields/payment Provides the format for Stripe Secret and Public API keys required for test and production environments. ```text Key Name| Format ---|--- Secret Key| `sk_xxxxxxxxxxxxxxxxxxxxxx` Public Key| `pk_xxxxxxxxxxxxxxxxxxxxxx` ``` -------------------------------- ### Get Multiple Countries by Code Source: https://www.acf-extended.com/features/fields/countries Retrieves a list of countries based on their codes. The output includes detailed information for each country. ```php $countries = acfe_get_countries(array( 'code__in' => array('us') )); /** * array( * 'us' => array( * 'code' => 'us', * 'name' => 'United States', * 'localized' => 'United States', * 'native' => 'United States', * 'dial' => array( * '1', * ), * 'capital' => 'Washington, D.C.', * 'people' => 'American', * 'continent' => 'America', * 'coords' => array( * 'lat' => 38.0, * 'lng' => -97.0, * ), * 'languages' => array( * 'en_US', * ), * 'currencies' => array( * 'USD', * ), * ), * ) */ ``` -------------------------------- ### Access Daterangepicker Object on Init Source: https://www.acf-extended.com/features/fields/date-range-picker Example of using the 'acfe/fields/date_range_picker/init' action to retrieve the daterangepicker object associated with the input. ```javascript acf.addAction('acfe/fields/date_range_picker/init/name=my_date_range', function($input, field){ // retrieve the daterangepicker object var daterangepicker = $input.data('daterangepicker'); }); ``` -------------------------------- ### Get Multiple Languages by Locale Source: https://www.acf-extended.com/features/fields/languages Retrieve multiple language configurations by specifying an array of locales. This returns a detailed array for each matching language. ```php $languages = acfe_get_languages(array( 'locale__in' => array('en_CA') )); /** * array( * 'en_CA' => array( * 'code' => 'en', * 'locale' => 'en_CA', * 'alt' => 'en_US', * 'name' => 'English', * 'native' => 'English', * 'dir' => 'ltr', * 'flag' => 'ca', * 'continent' => 'America', * 'countries' => array( * 'ca', * ), * 'currencies' => array( * 'CAD', * ), * ), * ) */ ``` -------------------------------- ### Multi-Step Form Setup Source: https://www.acf-extended.com/features/modules/forms/helpers Demonstrates setting up multiple forms acting as steps on the same page. It checks the success of each form sequentially to display the next step or final content. ```php // no form was submitted if(!acfe_is_form_success()){ // display form-1 acfe_form(array( 'name' => 'my-form-1' )); // form-1 was submitted }elseif(acfe_is_form_success('my-form-1')){ // display form-2 acfe_form(array( 'name' => 'my-form-2' )); // form-2 was submitted }elseif(acfe_is_form_success('my-form-2')){ // display form-3 acfe_form(array( 'name' => 'my-form-3' )); } ``` -------------------------------- ### Script Start Action Source: https://www.acf-extended.com/features/modules/scripts/script-launcher Implement the 'acfe/script_launcher/start' action to perform preparation tasks before the main script execution. This is optional and can be specific to a script name. ```php /** * acfe/script_launcher/start */ action('acfe/script_launcher/start', $script); action('acfe/script_launcher/start/name=my_script', $script); ``` ```php add_action('acfe/script_launcher/start/name=my_script', 'my_script_start'); function my_script_start($script){ // collecting data... // send message $script->send_response(array( 'message' => 'Script started. Collecting data...', 'status' => 'success', )); } ``` -------------------------------- ### Get Date Range Picker Start Date (Formatted) Source: https://www.acf-extended.com/features/fields/date-range-picker Retrieves the formatted start date for a Date Range Picker field using the get_field() function. ```php $date_range_start = get_field('date_range_start'); // 24/04/2021 ``` -------------------------------- ### Get Date Range Picker Start Date (Unformatted) Source: https://www.acf-extended.com/features/fields/date-range-picker Retrieves the unformatted start date for a Date Range Picker field using get_field() with 'false, false' arguments. ```php $date_range_start = get_field('date_range_start', false, false); // 20210424 ``` -------------------------------- ### Get Date Range Picker Value (Formatted) Source: https://www.acf-extended.com/features/fields/date-range-picker Retrieves the formatted start and end dates for a Date Range Picker field using the get_field() function. The values are returned as an associative array. ```php $date_range = get_field('date_range'); /** * array( * 'start' => '24/04/2021', * 'end' => '28/04/2021' * ) */ ``` -------------------------------- ### Get Date Range Picker Value (Unformatted) Source: https://www.acf-extended.com/features/fields/date-range-picker Retrieves the unformatted start and end dates for a Date Range Picker field using get_field() with 'false, false' arguments. This format is suitable for WP_Query. ```php $date_range = get_field('date_range', false, false); /** * array( * 'start' => '20210424', * 'end' => '20210428' * ) */ ``` -------------------------------- ### Custom Redirect Action Validation Example Source: https://www.acf-extended.com/features/modules/forms/actions/redirect Example of how to add custom validation logic for the Redirect Action using the `acfe/form/validate_redirect` hook. This example prevents redirection if a specific field's value is 'Company'. ```php add_action('acfe/form/validate_redirect/form=my-form', 'my_redirect_validation', 10, 2); function my_redirect_validation($form, $action){ // get current post id // where the form is displayed $post_id = $form['post_id']; // get field input value $my_field = get_field('my_field'); // check field value if($my_field === 'Company'){ // add validation error acfe_add_validation_error('my_field', 'The value Company is not allowed'); } } ``` -------------------------------- ### Native ACF Meta Structure Example Source: https://www.acf-extended.com/features/modules/performance-mode/hybrid-engine Demonstrates the standard meta structure used by ACF without the Hybrid Engine. This serves as a comparison to highlight the efficiency gains of the Hybrid Engine. ```php field_5ffd218f27704 Vestibulum ac diam sit amet field_5ffd218f27704 Curabitur placerat non leo field_5ffd27b80a8af 20210831 ``` -------------------------------- ### ACFE Save Term Taxonomy Example Source: https://www.acf-extended.com/features/hooks-helpers/save-post An example function hooked to 'acfe/save_term/taxonomy=category' for processing category term data before saving. ```php add_action('acfe/save_term/taxonomy=category', 'my_acfe_save_category', 10, 2); function my_acfe_save_category($post_id, $object){ // Retrieve the user input from "my_field" field get_field('my_field'); // Retrieve "my_field" field value from DB get_field('my_field', $post_id); // Loop thru the user input from "my_repeater" field if(have_rows('my_repeater')): while(have_rows('my_repeater')): the_row(); get_sub_field('my_sub_field'); endwhile; endif; } ``` -------------------------------- ### Enable Hybrid Engine with Configuration Array Source: https://www.acf-extended.com/features/modules/performance-mode/hybrid-engine Enable the Performance Mode with specific configurations by passing an array to 'acfe/init'. This allows setting engine, UI, and mode directly. ```php add_action('acfe/init', 'my_acfe_modules'); function my_acfe_modules(){ // enable performance mode with config acfe_update_setting('modules/performance', array( 'engine' => 'hybrid', 'ui' => true, 'mode' => 'test', )); } ``` -------------------------------- ### ACFE Save Options Page Slug Example Source: https://www.acf-extended.com/features/hooks-helpers/save-post An example function hooked to 'acfe/save_option/slug=my-options-page' for processing options page data before saving. ```php add_action('acfe/save_option/slug=my-options-page', 'my_acfe_save_options_page', 10, 2); function my_acfe_save_options_page($post_id, $object){ // Retrieve the user input from "my_field" field get_field('my_field'); // Retrieve "my_field" field value from DB get_field('my_field', $post_id); // Loop thru the user input from "my_repeater" field if(have_rows('my_repeater')): while(have_rows('my_repeater')): the_row(); get_sub_field('my_sub_field'); endwhile; endif; } ``` -------------------------------- ### ACFE Save Post Type Example Source: https://www.acf-extended.com/features/hooks-helpers/save-post Example of a custom function hooked to 'acfe/save_post/post_type=page' to process field data upon saving a page. ```php add_action('acfe/save_post/post_type=page', 'my_acfe_save_page', 10, 2); function my_acfe_save_page($post_id, $object){ // Retrieve the user input from "my_field" field get_field('my_field'); // Retrieve "my_field" field value from DB get_field('my_field', $post_id); // Loop thru the user input from "my_repeater" field if(have_rows('my_repeater')): while(have_rows('my_repeater')): the_row(); get_sub_field('my_sub_field'); endwhile; endif; } ``` -------------------------------- ### Post Object Field Example Source: https://www.acf-extended.com/features/fields/post-object Demonstrates the basic usage of the Post Object field, showing selected posts. This is a visual representation of the field's output. ```html Post Object Page 1Page 1 **** Add New Post Object Page 1Post 3 * ×Page 1 * ×Post 3 * Add New ``` -------------------------------- ### Bidirectional Fields Configuration Examples Source: https://www.acf-extended.com/features/field-settings/bidirectional-fields Illustrates various configurations for bidirectional field linking, including Post <> Post, Taxonomy <> Taxonomy, Taxonomy <> User, Taxonomy <> Post, User <> Post, and User <> User relationships. ```markdown ┌ Display a Post Object field on "Post Type A" showing "Post Type B" └ Display a Post Object field on "Post Type B" showing "Post Type A" ``` ```markdown ┌ Display a Taxonomy field on "Taxonomy A" showing "Taxonomy B" └ Display a Taxonomy field on "Taxonomy B" showing "Taxonomy A" ``` ```markdown ┌ Display a Taxonomy field on "Users" showing "Taxonomy A" └ Display a User field on "Taxonomy A" showing "Users" ``` ```markdown ┌ Display a Taxonomy field on "Post Type A" showing "Taxonomy A" └ Display a Post Object field on "Taxonomy A" showing "Post Type A" ``` ```markdown ┌ Display a User field on "Post Type A" showing "Users" └ Display a Post Object field on "Users" showing "Post Type A" ``` ```markdown ┌ Display a User field on "Users" showing "Editor" └ Display a User field on "Users" showing "Admin" ``` -------------------------------- ### Get Formatted Slug Value Source: https://www.acf-extended.com/features/fields/slug Retrieves the formatted slug value from the 'slug' field. This is the standard way to get the field's value. ```php $slug = get_field('slug'); // my-slug ``` -------------------------------- ### Front-End Render with have_settings() Source: https://www.acf-extended.com/features/fields/flexible-content/modal-settings This snippet demonstrates how to render clone sub fields on the front-end using the dedicated `have_settings()` helper loop. ```php if(have_settings()): while(have_settings()): the_setting(); $setting = get_sub_field('my_setting'); endwhile; endif; ``` -------------------------------- ### Enable Hybrid Engine using acfe/init Source: https://www.acf-extended.com/features/modules/performance-mode/hybrid-engine Enable the Performance Mode with the Hybrid Engine using the 'acfe/init' hook and acfe_update_setting. ```php add_action('acfe/init', 'my_acfe_modules'); function my_acfe_modules(){ // enable performance mode with hybrid engine acfe_update_setting('modules/performance', 'hybrid'); } ``` -------------------------------- ### Hybrid Engine Meta Structure Example Source: https://www.acf-extended.com/features/modules/performance-mode/hybrid-engine Illustrates the meta structure when using the Hybrid Engine. It shows how ACF Extended stores field references and values, contrasting with the native ACF structure. ```php Array ( [_my_field] => field_5ffd218f27704 [_my_content] => field_5ffd218f27704 [_my_date] => field_5ffd27b80a8af ) a:3:{s:9:"_my_field";s:19:"field_5ffd218f27704";s:11:"_my_content";s:19:"field_5ffd218f27704";s:8:"_my_date";s:19:"field_5ffd27b80a8af";} ``` -------------------------------- ### Customizing Taxonomy Terms Display Source: https://www.acf-extended.com/features/fields/taxonomy-terms Example of a custom function hooked into the 'acfe/fields/taxonomy_terms/result' filter to change the term name display. This example bolds the term name. ```php add_filter('acfe/fields/taxonomy_terms/result/name=my_taxonomy_terms', 'my_acf_taxonomy_terms_result', 10, 4); function my_acf_taxonomy_terms_result($text, $term, $field, $post_id){ // change term name result $text = "{$text}"; // return return $text; } ``` -------------------------------- ### Example Field Settings Array Source: https://www.acf-extended.com/features/field-settings/field-advanced-settings Illustrates the structure of settings returned by `acf_get_field()`, showing options like placeholder, instructions, required, conditional logic, wrapper attributes, choices, default value, and more. ```php /* * Array * ( * ... * [placeholder] => * [instructions] => Vivamus magna justo, lacinia eget. * [required] => 0 * [conditional_logic] => 0 * [wrapper] => Array * ( * [width] => * [class] => * [id] => * ) * [choices] => Array * ( * [choice_1] => Choice 1 * [choice_2] => Choice 2 * [choice_3] => Choice 3 * [choice_4] => Choice 4 * ) * [default_value] => * [allow_null] => 0 * [multiple] => 0 * [ui] => 0 * [ajax] => 0 * [return_format] => value * ... * ) */ ``` -------------------------------- ### Enable Force Sync Module using acf/init Source: https://www.acf-extended.com/features/field-groups/force-sync Enable the Force Sync module by updating the ACF setting for modules. This method uses the 'acf/init' hook. ```php // Using acf/init add_action('acf/init', 'my_acfe_modules'); function my_acfe_modules(){ // Enable Force Sync acf_update_setting('acfe/modules/force_sync', true); } ``` -------------------------------- ### Enable Performance Mode with UI Source: https://www.acf-extended.com/features/modules/performance-mode/ultra-engine Enables Performance Mode with the Ultra Engine and displays a metabox for on-demand mode switching. Developer Mode must be enabled for the UI to appear. ```php add_action('acf/init', 'my_acfe_modules'); function my_acfe_modules(){ // enable performance mode // with ultra engine (default) + metabox acf_update_setting('acfe/modules/performance', array( 'ui' => true, )); } ``` -------------------------------- ### User Arguments Filter Examples Source: https://www.acf-extended.com/features/modules/forms/actions/user These examples show how to use the 'acfe/form/submit_user_args' filter to modify user arguments before they are passed to WordPress user functions. You can target specific forms or actions. ```php /** * User Action: Arguments * * @array $args User arguments, later passed to wp_insert_user() * @array $form Form settings array * @array $action Action settings array * * @return array|false */ filter('acfe/form/submit_user_args', $args, $form, $action); filter('acfe/form/submit_user_args/form=my-form', $args, $form, $action); filter('acfe/form/submit_user_args/action=my-user', $args, $form, $action); ``` -------------------------------- ### Enable Force Sync Module using acfe/init Source: https://www.acf-extended.com/features/field-groups/force-sync Enable the Force Sync module by updating the ACF Extended setting for modules. This method uses the 'acfe/init' hook. ```php // Or using acfe/init add_action('acfe/init', 'my_acfe_modules'); function my_acfe_modules(){ // Enable Force Sync acfe_update_setting('modules/force_sync', true); } ``` -------------------------------- ### Control User Action Preparation Logic Source: https://www.acf-extended.com/features/modules/forms/actions/user Implement the `acfe/form/prepare_user` filter to control the preparation phase before user form submission. Returning `false` stops the action. ```php add_filter('acfe/form/prepare_user/form=my-form', 'my_user_prepare', 10, 2); function my_user_prepare($action, $form){ // if user isn't logged in // do not create/update the user if(!is_user_logged_in()){ return false; } // return normally return $action; } ``` -------------------------------- ### Validate Save Post Hook Examples Source: https://www.acf-extended.com/features/hooks-helpers/validate-save-post Shows how to use the 'acfe/validate_save_post' hook to specifically validate post data. Includes examples for targeting specific post IDs and post types. ```php /* * ACFE Validate Save Post * * @string $post_id The Post ID * @object $object The WP Post Object */ action('acfe/validate_save_post', $post_id, $object); action('acfe/validate_save_post/id=12', $post_id, $object); action('acfe/validate_save_post/post_type=page', $post_id, $object); ``` ```php add_action('acfe/validate_save_post/post_type=page', 'my_acfe_validate_save_page', 10, 2); function my_acfe_validate_save_page($post_id, $object){ // Retrieve the user input from "my_field" field get_field('my_field'); // Retrieve "my_field" field value from DB get_field('my_field', $post_id); // Loop thru the user input from "my_repeater" field if(have_rows('my_repeater')): while(have_rows('my_repeater')): the_row(); get_sub_field('my_sub_field'); endwhile; endif; // Add a custom validation error acfe_add_validation_error('my_field', 'This is a custom error'); } ``` -------------------------------- ### Disable Enforced Field Validation Examples Source: https://www.acf-extended.com/features/modules/forms/hooks Examples demonstrating how to disable enforced front-end validation for specific fields, field types, or all fields within a particular form using the 'acfe/form/pre_validate_value' filter. ```php // disable enforced front-end validation for "my_field" add_filter('acfe/form/pre_validate_value/name=my_field', '__return_false'); // disable enforced front-end validation for all "checkbox" fields add_filter('acfe/form/pre_validate_value/type=checkbox', '__return_false'); // disable enforced front-end validation for all fields from "my-form" add_filter('acfe/form/pre_validate_value/form=my-form', '__return_false'); ``` -------------------------------- ### Enable Developer Mode using acfe/init Source: https://www.acf-extended.com/features/modules/developer-mode Enable developer mode by hooking into the `acfe/init` action and using `acfe_update_setting`. ```php add_action('acfe/init', 'my_acfe_modules'); function my_acfe_modules(){ // enable developer mode acfe_update_setting('dev', true); } ``` -------------------------------- ### Enable Performance Mode with Configuration Array via Setting Source: https://www.acf-extended.com/features/modules/performance-mode/ultra-engine Enables Performance Mode and provides a configuration array, including engine, UI, and mode, directly within the 'acfe/init' hook. ```php add_action('acfe/init', 'my_acfe_modules'); function my_acfe_modules(){ // enable performance mode with config acfe_update_setting('modules/performance', array( 'engine' => 'ultra', 'ui' => true, 'mode' => 'test', )); } ``` -------------------------------- ### Enable Performance Mode using acfe/init Source: https://www.acf-extended.com/features/modules/performance-mode/ultra-engine Enables the Performance Mode with the Ultra Engine using the 'acfe/init' hook. This is an alternative method for enabling the module. ```php add_action('acfe/init', 'my_acfe_modules'); function my_acfe_modules(){ // enable performance mode with ultra engine (default) acfe_update_setting('modules/performance', true); } ``` -------------------------------- ### Post Action: Custom Validation Example Source: https://www.acf-extended.com/features/modules/forms/actions/post Example of how to add custom validation logic for a post action. This function checks a specific field's value and adds a validation error if it's not allowed. ```php add_action('acfe/form/validate_post/form=my-form', 'my_post_validation', 10, 2); function my_post_validation($form, $action){ // get current post id // where the form is displayed $post_id = $form['post_id']; // get field input value $my_field = get_field('my_field'); // check field value if($my_field === 'Company'){ // add validation error acfe_add_validation_error('my_field', 'The value Company is not allowed'); } } ``` -------------------------------- ### Custom Action Validation Hook Example Source: https://www.acf-extended.com/features/modules/forms/actions/custom This example demonstrates how to use the 'acfe/form/validate_my-action' hook to validate a specific field's value before form submission. It checks if 'my_field' has the value 'Company' and adds a validation error if it does. ```php add_action('acfe/form/validate_my-action', 'my_form_validation', 10, 2); function my_form_validation($form, $action){ // get current post id // where the form is displayed $post_id = $form['post_id']; // get field input value $my_field = get_field('my_field'); // check field value if($my_field === 'Company'){ // add validation error acfe_add_validation_error('my_field', 'The value Company is not allowed'); } } ``` -------------------------------- ### Enable Demo Scripts Source: https://www.acf-extended.com/features/modules/scripts Enable the demo scripts feature for the Scripts UI module. This is useful for testing and exploring different script implementations. ```php add_action('acf/init', 'my_acfe_modules'); function my_acfe_modules(){ // enable demo scripts acf_update_setting('acfe/modules/scripts/demo', true); } ``` -------------------------------- ### ACF Extended Save Comment Hook Example Source: https://www.acf-extended.com/features/hooks-helpers/save-post Demonstrates how to hook into the `acfe/save_comment` action to perform custom logic when a comment is saved. This example shows how to target a specific comment ID and access field data. ```php /* * ACFE Save Comment * * @string $post_id The ACF Comment ID * @object $object The WP Comment Object */ action('acfe/save_comment', $post_id, $object); action('acfe/save_comment/id=comment_89', $post_id, $object); ``` ```php add_action('acfe/save_comment/id=comment_89', 'my_acfe_save_comment', 10, 2); function my_acfe_save_comment($post_id, $object){ // Retrieve the user input from "my_field" field get_field('my_field'); // Retrieve "my_field" field value from DB get_field('my_field', $post_id); // Loop thru the user input from "my_repeater" field if(have_rows('my_repeater')): while(have_rows('my_repeater')): the_row(); get_sub_field('my_sub_field'); endwhile; endif; } ``` -------------------------------- ### Enable Performance Mode using acf/init Source: https://www.acf-extended.com/features/modules/performance-mode/ultra-engine Enables the Performance Mode with the Ultra Engine using the 'acf/init' hook. This is the default method for enabling the module. ```php add_action('acf/init', 'my_acfe_modules'); function my_acfe_modules(){ // enable performance mode with ultra engine (default) acf_update_setting('acfe/modules/performance', true); } ``` -------------------------------- ### Custom Start and Stop Logic in ACF Extended Scripts Source: https://www.acf-extended.com/features/modules/scripts/custom-script Override the default start and stop methods to perform custom actions and provide specific feedback to the user. This is useful for data collection, cleanup, and status updates. ```php if(!class_exists('my_acfe_script')): class my_acfe_script extends acfe_script{ /** * initialize */ function initialize(){ $this->name = 'my_script'; $this->title = 'My Script'; } /** * start */ function start(){ // collect data... // override default 'Start' message $this->send_response(array( 'message' => 'Script started. Collecting data...', 'status' => 'success', )); } /** * request */ function request(){ // do something... // call the stop() method $this->send_response(array( 'event' => 'stop', )); } /** * stop */ function stop(){ // cleanup data... // override default 'Stop' message $this->send_response(array( 'message' => 'Script finished. Cleanup data.', 'status' => 'success', )); } } // register acfe_register_script('my_acfe_script'); endif; ``` -------------------------------- ### Enable Performance Mode with Ultra Engine via Setting Source: https://www.acf-extended.com/features/modules/performance-mode/ultra-engine Enables Performance Mode and specifies the Ultra Engine directly within the 'acfe/init' hook by passing 'ultra' as the setting value. ```php add_action('acfe/init', 'my_acfe_modules'); function my_acfe_modules(){ // enable performance mode with ultra engine acfe_update_setting('modules/performance', 'ultra'); } ``` -------------------------------- ### Enable Hybrid Engine using acf/init Source: https://www.acf-extended.com/features/modules/performance-mode/hybrid-engine Enable the Performance Mode with the Hybrid Engine by updating the ACF setting via the 'acf/init' hook. ```php add_action('acf/init', 'my_acfe_modules'); function my_acfe_modules(){ // enable performance mode with hybrid engine acf_update_setting('acfe/modules/performance', 'hybrid'); } ``` -------------------------------- ### Option Action: Validation Hook Example Source: https://www.acf-extended.com/features/modules/forms/actions/option This example demonstrates how to use the 'acfe/form/validate_option' hook to add custom validation rules for the Option Action. It shows how to access form and action settings, retrieve field values, and use 'acfe_add_validation_error' to flag invalid input. ```php /** * Option Action: Validation * * @array $form Form settings array * @array $action Action settings array */ action('acfe/form/validate_option', $form, $action); action('acfe/form/validate_option/form=my-form', $form, $action); action('acfe/form/validate_option/action=my-option', $form, $action); ``` ```php add_action('acfe/form/validate_option/form=my-form', 'my_option_validation', 10, 2); function my_option_validation($form, $action){ // get current post id // where the form is displayed $post_id = $form['post_id']; // get field input value $my_field = get_field('my_field'); // check field value if($my_field === 'Company'){ // add validation error acfe_add_validation_error('my_field', 'The value Company is not allowed'); } } ``` -------------------------------- ### Get Form Input Values with ACF Extended Source: https://www.acf-extended.com/features/modules/forms/helpers Retrieve all input values or specific field values submitted within an ACF Extended form. Use `get_field()` and `get_sub_field()` without a post ID to get unformatted input values. Supports retrieving repeater sub-fields. ```php add_action('acfe/form/submit_form/form=my-form', 'my_form_submission'); function my_form_submission($form){ $inputs = get_fields(); // all inputs values $inputs = get_fields(false, false); // all inputs values (unformatted) $my_field = get_field('my_field'); // input value $my_field = get_field('my_field', false, false); // input value (unformatted) if(have_rows('my_repeater')): while(have_rows('my_repeater')): the_row(); $sub_field = get_sub_field('sub_field'); // subfield input value $sub_field = get_sub_field('sub_field', false); // subfield input value (unformatted) endwhile; endif; } ``` -------------------------------- ### Dynamic Render Layout Settings Source: https://www.acf-extended.com/features/fields/flexible-content/dynamic-render Configure template, JavaScript, and CSS files for individual layouts. Ensure 'Advanced Settings' are enabled in the Flexible Content field group. ```markdown Setting name| Description ---|--- Template File| (Optional) The layout PHP template file. Javascript File| (Optional) The layout Javascript file. Style File| (Optional) The layout CSS file. ``` -------------------------------- ### Get All Form Actions Output Source: https://www.acf-extended.com/features/modules/forms/helpers Retrieves the outputs of all actions within a form. ```php /** * Get All Actions Output * * @return array */ acfe_get_form_actions() ``` -------------------------------- ### Enable Developer Mode using acf/init Source: https://www.acf-extended.com/features/modules/developer-mode Enable developer mode by hooking into the `acf/init` action and using `acf_update_setting`. ```php add_action('acf/init', 'my_acfe_modules'); function my_acfe_modules(){ // enable developer mode acf_update_setting('acfe/dev', true); } ``` -------------------------------- ### Get Unformatted Phone Number Value Source: https://www.acf-extended.com/features/fields/phone-number Retrieves the raw, unformatted phone number value from the field. ```php $phone_number = get_field('phone_number', false, false); // +12015550123 ``` -------------------------------- ### Non-Recursive ACF Extended Script Source: https://www.acf-extended.com/features/modules/scripts/custom-script Example of a basic non-recursive script. The request() method is called once to process all posts. ```php if(!class_exists('my_acfe_script')): class my_acfe_script extends acfe_script{ /** * initialize */ function initialize(){ $this->name = 'my_script'; $this->title = 'My Script'; // script is non-recursive by default } /** * request */ function request(){ $posts = get_posts(array( 'post_type' => 'post', 'posts_per_page' => -1, // get all posts 'fields' => 'ids', )); if($posts){ foreach($posts as $post_id){ $my_field = get_field('my_field', $post_id); // do something... } } } } // register acfe_register_script('my_acfe_script'); endif; ``` -------------------------------- ### Environment Configuration for ACF Extended Pro Source: https://www.acf-extended.com/features/getting-started/installation Create an .env file at the root of your WordPress install to configure license key and domain. Ensure the domain matches the one activated on your license. ```env ACFE_PRO_KEY=YOUR_LICENSE_KEY_HERE ACFE_PRO_URL=www.your-site.com ```