Action
uncanny-automator
automator_before_configure
Fires before the Automator configuration is saved, allowing for modifications or validation of settings.
add_action( 'automator_before_configure', $callback, 10, 1 );
Description
Fires before Automator's core configuration and initialization. Developers can use this hook to perform custom actions or modify settings before Automator loads its database and utilities. This is an opportune moment to inject custom logic or integrate with other systems during the plugin's setup phase.
Usage
add_action( 'automator_before_configure', 'your_function_name', 10, 1 );
Examples
add_action( 'automator_before_configure', 'my_automator_custom_setup', 10, 0 );
/**
* Example function to demonstrate the 'automator_before_configure' hook.
* This function could be used to perform custom setup tasks before the Automator plugin
* fully initializes its configuration. For instance, it might check for specific
* plugin dependencies or prepare custom database tables if needed.
*/
function my_automator_custom_setup() {
// Check if a specific custom option is set in WordPress options table.
// If it is, we might want to alter some default Automator behavior.
$custom_setting = get_option( 'my_automator_enable_advanced_features', false );
if ( $custom_setting === 'yes' ) {
// Example: Log a message indicating advanced features are enabled.
// In a real scenario, you might enqueue custom scripts,
// register custom post types, or modify Automator's internal settings.
error_log( 'Automator advanced features are enabled. Performing custom setup...' );
// Example: Perform some custom database setup if necessary.
// This is a placeholder; actual database operations would be more complex.
// For example, you might check if a custom table exists and create it.
// global $wpdb;
// $table_name = $wpdb->prefix . 'my_automator_custom_data';
// if ( $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) != $table_name ) {
// $charset_collate = $wpdb->get_charset_collate();
// $sql = "CREATE TABLE $table_name (
// id mediumint(9) NOT NULL AUTO_INCREMENT,
// created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
// data text NOT NULL,
// PRIMARY KEY (id)
// ) $charset_collate;";
// require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
// dbDelta( $sql );
// }
} else {
// Log a message if advanced features are not enabled.
error_log( 'Automator standard configuration will proceed.' );
}
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/class-automator-load.php:387
src/core/classes/class-initialize-automator.php:120
public function load_automator() {
// If it's not required to load automator, bail
if ( false === LOAD_AUTOMATOR ) {
return;
}
do_action( 'automator_before_configure' );
// Load Utilities
$this->initialize_utilities();
// Load Configuration
$this->initialize_automator_db();
// Load the core files
$this->initialize_core_automator();
// Load the services.
$this->load_services();
// Load system overwrites.
$this->load_overwrites();
do_action( 'automator_configuration_complete' );
add_action( 'wpforms_loaded', array( $this, 'wpforms_integration' ) );
}