AI Summary
Description
The wpforms_loaded action fires once WPForms has set up its core objects and is ready for use. It runs on plugins_loaded, right after the form handler and process objects are registered, and before the admin loader, providers, and integrations initialize.
This action does not accept any parameters.
More Information
WPForms::hooks() attaches objects() to plugins_loaded. objects() creates WPForms_Form_Handler and WPForms_Process in the registry and then fires do_action( 'wpforms_loaded' ) with no arguments. Core itself listens on it to start Admin\Loader (admin only), Providers\Providers, and Integrations\Loader, all at priority 10.
Use it to register hooks that need wpforms() to exist, or to run code only when WPForms is active. The reference articles below wrap their setup in it: one registers a wpforms_entry_email_data filter, the other boots a Quiz and Survey Master compatibility class. Integrations also start at priority 10 on this action, so a callback that has to run before an integration constructs its objects (for example the PayPal Commerce payment methods) needs a lower priority number.
Fires in Lite and Pro. It does not fire when WPForms::is_restricted_heartbeat() short-circuits init(), because hooks() is never reached. WPForms addons boot on this action as well.
Source
wpforms/src/WPForms.php
Example
This example registers a notification filter only after WPForms is loaded, so the callback never runs when WPForms is inactive.
/**
* Register WPForms hooks once the plugin is loaded.
*
* @link https://wpforms.com/developers/wpforms_loaded/
*/
function wpf_dev_loaded() {
add_filter( 'wpforms_entry_email_data', 'wpf_dev_remove_field_from_email', 11, 3 );
}
add_action( 'wpforms_loaded', 'wpf_dev_loaded', 10, 0 );
/**
* Remove field 3 from {all_fields} in notifications for form 143.
*
* @param array $fields Entry fields.
* @param array $entry Form submission raw data.
* @param array $form_data Form data and settings.
*
* @return array
*/
function wpf_dev_remove_field_from_email( $fields, $entry, $form_data ) {
// Only run on the form with ID 143. Remember to change 143 to your form ID.
if ( empty( $form_data['id'] ) || (int) $form_data['id'] !== 143 ) {
return $fields;
}
// Remember to change 3 to the ID of the field you want to remove.
unset( $fields[3] );
return $fields;
}




