Action uncanny-continuing-education-credits

uncanny_owl_notifications_before_init

Fires before the Uncanny Owl Notifications core system is initialized, allowing for early modifications.

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

Description

Fires before Uncanny Owl Notifications is initialized. Developers can use this hook to perform actions or modify settings before the notification system is fully set up. `$this` refers to the Uncanny Owl Notifications instance.


Usage

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

Examples

<?php
/**
 * Example function hooked into uncanny_owl_notifications_before_init.
 *
 * This function demonstrates how to conditionally enable or disable
 * specific notification features before the main initialization occurs.
 * For instance, we might disable a certain notification type if a plugin conflict is detected.
 */
add_action( 'uncanny_owl_notifications_before_init', 'my_custom_notification_setup', 10, 1 );

function my_custom_notification_setup( $notification_instance ) {

	// Check if a specific condition is met. For example, if another plugin
	// is already handling a certain type of notification.
	if ( class_exists( 'Another_Notification_Plugin' ) ) {
		// Prevent Uncanny Owl from sending a specific type of notification if another plugin handles it.
		// Assuming $notification_instance has a method to disable notification types.
		if ( method_exists( $notification_instance, 'disable_notification_type' ) ) {
			$notification_instance->disable_notification_type( 'user_login_welcome' );
			error_log( 'Uncanny Owl: User login notification type disabled due to conflict with Another_Notification_Plugin.' );
		}
	}

	// You could also modify settings or add custom notification types here
	// before Uncanny Owl's own hooks and methods are called.
	// For example:
	// $notification_instance->add_custom_setting( 'my_custom_option', 'default_value' );

}
?>

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/notifications/notifications.php:81

public function init() {

			do_action( 'uncanny_owl_notifications_before_init', $this );

			$this->hooks();

		}

Scroll to Top