acf/init
Fires after the ACF plugin has been fully initialized.
This event is similar to the WordPress init event and should be used to extend or register items such as blocks, forms, and options pages.
This action normally fires during the WordPress init event at priority 5. However, if a field value is requested earlier somewhere in the code, this event will fire earlier. For example, when a field value is requested directly from functions.php.
Usage
add_action( 'acf/init', 'wp_kama_acf_init_action' );
/**
* Function for `acf/init` action-hook.
*
* @param int $ACF_MAJOR_VERSION ACF_MAJOR_VERSION The major version of ACF.
*
* @return void
*/
function wp_kama_acf_init_action( $ACF_MAJOR_VERSION ){
// action...
}
- $major_version(integer)
- The ACF major version. For example, the major version of ACF
5.2.3is5.
Examples
#1 Usage demonstration
add_action( 'acf/init', 'my_acf_init' );
function my_acf_init() {
// Get the ACF version.
$version = acf_get_setting('version');
// Do something.
}Changelog
| Since 5.0.0 | Introduced. |
Where the hook is called
acf/init
acf/acf.php 489
do_action( 'acf/init', ACF_MAJOR_VERSION );
Where the hook is used in Advanced Custom Fields PRO
acf/includes/Updater/init.php 73
add_action( 'acf/init', 'acf_register_free_updates' );
acf/includes/admin/tools/class-acf-admin-tool-export.php 409
echo "add_action( 'acf/init', function() {\r\n";
acf/includes/compatibility.php 56
add_action( 'acf/init', array( $this, 'init' ) );
acf/includes/post-types/class-acf-post-type.php 84
add_action( 'acf/init', array( $this, 'register_post_types' ), 6 );
acf/includes/post-types/class-acf-taxonomy.php 84
add_action( 'acf/init', array( $this, 'register_taxonomies' ), 6 );
acf/pro/acf-pro.php 60
add_action( 'acf/init', array( $this, 'update_plugin_name' ) );
acf/pro/post-types/acf-ui-options-page.php 85
add_action( 'acf/init', array( $this, 'register_ui_options_pages' ), 6 );
acf/src/AI/AI.php 30
add_action( 'acf/init', array( $this, 'initialize' ) );
acf/src/Blocks/Bindings.php 30
add_action( 'acf/init', array( $this, 'register_binding_sources' ) );