Action uncanny-continuing-education-credits

ceu_deactivation_after

Fires after the course plugin is deactivated to allow for cleanup tasks.

add_action( 'ceu_deactivation_after', $callback, 10, 1 );

Description

Fires after core deactivation routines have completed. Developers can use this hook to perform any necessary cleanup, such as removing custom database tables, deleting options, or unregistering custom post types. It's executed within the `deactivation()` function.


Usage

add_action( 'ceu_deactivation_after', 'your_function_name', 10, 1 );

Examples

// Remove any scheduled cleanup tasks that were set up during plugin activation.
// This prevents old data from lingering unnecessarily after the plugin is deactivated.
add_action( 'ceu_deactivation_after', function() {

    // Example: If your plugin scheduled a daily cleanup cron job.
    // Check if the cron job exists before trying to remove it.
    if ( wp_next_scheduled( 'my_plugin_daily_cleanup_hook' ) ) {
        wp_clear_scheduled_hook( 'my_plugin_daily_cleanup_hook' );
    }

    // Example: Clean up custom database tables if your plugin created any.
    // This is a simplified example; in reality, you'd likely want more robust checks.
    global $wpdb;
    $table_name = $wpdb->prefix . 'my_plugin_data';
    // Uncomment the line below to actually drop the table if it exists.
    // $wpdb->query( "DROP TABLE IF EXISTS {$table_name}" );

    // Example: Remove any custom options that might be left behind.
    delete_option( 'my_plugin_settings' );
    delete_option( 'my_plugin_activation_timestamp' );

}, 10, 0 ); // 10 is the priority, 0 is the number of accepted arguments.

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/config.php:200

function deactivation() {

		do_action( 'ceu_deactivation_before' );

		do_action( 'ceu_deactivation_after' );

	}


Scroll to Top