ulgm_deactivation_before
Fires before the plugin is deactivated, allowing for custom cleanup or actions.
add_action( 'ulgm_deactivation_before', $callback, 10, 1 );
Description
Fires just before the plugin performs its deactivation routine. Developers can use this hook to perform custom cleanup, save data, or execute any necessary actions before the plugin is fully deactivated. It runs as part of the core deactivation process.
Usage
add_action( 'ulgm_deactivation_before', 'your_function_name', 10, 1 );
Examples
add_action( 'ulgm_deactivation_before', 'my_ulgm_custom_deactivation_logic', 10 );
/**
* Example function to demonstrate the 'ulgm_deactivation_before' action hook.
* This function would typically perform custom cleanup or logging before
* the main plugin deactivation routines run.
*/
function my_ulgm_custom_deactivation_logic() {
// Log a message to the debug log to indicate that the deactivation process has started.
if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
error_log( 'ULGM deactivation process initiated. Performing custom pre-deactivation tasks.' );
}
// Example: Clear a specific transient data related to ULGM if it exists.
// In a real scenario, this would be more specific to what your plugin does.
$transient_key = 'ulgm_settings_cache_' . get_current_blog_id();
if ( false !== get_transient( $transient_key ) ) {
delete_transient( $transient_key );
if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
error_log( 'Cleared ULGM settings transient: ' . $transient_key );
}
}
// Example: Perhaps you want to run a custom cleanup process for user meta
// that is specific to your plugin and not handled by the main deactivation.
// For demonstration, let's imagine we have a function to clean up old user meta.
// if ( function_exists( 'my_ulgm_cleanup_user_meta' ) ) {
// my_ulgm_cleanup_user_meta();
// }
}
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/classes/class-setup.php:291
public function deactivation() {
do_action( 'ulgm_deactivation_before' );
// Set which roles will need access
$set_role_capabilities = array(
'group_leader' => array( 'ulgm_group_management' ),
'administrator' => array( 'ulgm_group_management' ),
);
/**
* Filters role based capabilities before being added
*
* @param string $set_role_capabilities Path to the plugins template folder
*
* @since 1.0.0
*
*/
$set_role_capabilities = apply_filters( 'ulgm_add_role_capabilities', $set_role_capabilities );
include_once ULGM_ABSPATH . 'src/includes/capabilities.php';
$capabilities = new Capabilities( $set_role_capabilities );
$capabilities->remove_capabilities();
do_action( 'ulgm_deactivation_after' );
}