Action uncanny-learndash-groups

ulgm_activation_before

Fires just before the plugin is activated, allowing for pre-activation modifications.

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

Description

Fires immediately before the plugin's database tables are initialized and new pages are generated during activation. Developers can use this hook to perform custom setup tasks before core plugin activation logic runs.


Usage

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

Examples

/**
 * Example function to hook into ulgm_activation_before.
 * This function might be used to perform some custom setup or checks
 * before the plugin's main activation routines run.
 * For instance, it could check for required PHP extensions or
 * set up initial user roles if needed.
 */
add_action( 'ulgm_activation_before', function() {

    // Check if the 'imagick' PHP extension is available, as it might be required
    // for some image manipulation features in the plugin.
    if ( ! extension_loaded( 'imagick' ) ) {
        // If not loaded, schedule an admin notice to inform the user.
        // This is a common practice for informing users about unmet dependencies.
        set_transient( 'ulgm_imagick_missing_notice', true, 5 * MINUTE_IN_SECONDS );
    }

    // You could also potentially pre-populate some default group categories here
    // if your custom integration requires specific initial structures.
    // For example:
    // if ( ! get_option( 'ulgm_default_categories_created' ) ) {
    //     // Code to create default categories...
    //     update_option( 'ulgm_default_categories_created', true );
    // }

}, 10, 0 ); // Priority 10, accepts 0 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/classes/class-setup.php:104

public function activation() {

		do_action( 'ulgm_activation_before' );

		// Add Groups DB tables
		$this->initialize_db();

		// Add Group Management pages
		$this->generate_groups_pages();

		do_action( 'ulgm_activation_after' );

	}


Scroll to Top