Home / Admin / Fixing WPForms Bulk Update Issues with WP Umbrella
Duplicate Snippet

Embed Snippet on Your Site

Fixing WPForms Bulk Update Issues with WP Umbrella

This code snippet will force the WPForms updater to run during the WP Umbrella snapshot request.

<10
Code Preview
php
<?php
add_action( 'set_current_user', 'wpforms_fix_umbrella_get_snapshot_data' );
/**
 * Executes the WPForms updater based on a specific POST request action, allowing a snapshot to be taken for WP Umbrella compatibility.
 */
function wpforms_fix_umbrella_get_snapshot_data() {
	// Check if this is a POST request with the specific action parameter.
	// phpcs:disable WordPress.Security.NonceVerification.Missing
	if (
		! isset( $_POST['action'] ) ||
		! class_exists( 'WPForms_Pro' ) ||
		sanitize_text_field( wp_unslash( $_POST['action'] ) ) !== 'wp_umbrella_snapshot_data'
	) {
		return;
	}
	// phpcs:enable WordPress.Security.NonceVerification.Missing
	// Try to find the WPForms Pro instance through the main plugin.
	$wpforms_pro = wpforms()->obj( 'pro' );
	// Call the updater method if the instance exists.
	if ( ! $wpforms_pro || ! method_exists( $wpforms_pro, 'updater' ) ) {
		return;
	}
	// Toggle the boolean property before running updater.
	add_filter( 'wpforms_updater_allow_load', '__return_true' );
	$wpforms_pro->updater();
	// Revert the boolean property after running updater.
	remove_filter( 'wpforms_updater_allow_load', '__return_true' );
}

Comments

Add a Comment