Filter uncanny-automator-pro

automator_pro_mp_usermemexpiresprod_allow_account_inactive_hook

Filters whether a MemberPress user account can be considered inactive for expiration purposes.

add_filter( 'automator_pro_mp_usermemexpiresprod_allow_account_inactive_hook', $callback, 10, 1 );

Description

Allows developers to control whether the "Membership product expires" trigger fires for inactive accounts. By default, it prevents the trigger from firing for inactive accounts. Developers can return `true` to enable it for inactive accounts, providing greater flexibility in automation scenarios.


Usage

add_filter( 'automator_pro_mp_usermemexpiresprod_allow_account_inactive_hook', 'your_function_name', 10, 1 );

Parameters

$arg (mixed)
This parameter is a boolean value, defaulting to `false`, that controls whether the trigger should run for inactive accounts.

Return Value

The filtered value.


Examples

/**
 * Example function to allow the 'mepr-account-is-inactive' action to trigger automations
 * even if the user's account is considered inactive by MemberPress.
 *
 * By default, Uncanny Automator Pro might prevent automations from triggering
 * on 'mepr-account-is-inactive' if the user isn't deemed active. This filter
 * provides a way to override that behavior.
 *
 * @param mixed $allow_inactive_trigger The current value of the filter, defaults to false.
 * @param mixed $arg                    The argument passed to the hook, can be MeprTransaction or MeprEvent.
 *
 * @return bool True if the inactive account trigger should be allowed, false otherwise.
 */
add_filter( 'automator_pro_mp_usermemexpiresprod_allow_account_inactive_hook', function( $allow_inactive_trigger, $arg ) {

    // Check if the current action is 'mepr-account-is-inactive'
    if ( current_action() === 'mepr-account-is-inactive' ) {
        // Let's say we want to allow the trigger for a specific membership product ID, e.g., 123.
        // We'd need to access the membership product information from the $arg.
        // The type of $arg depends on the specific MemberPress hook fired.
        // For 'mepr-account-is-inactive', $arg is typically a MeprTransaction object.

        if ( $arg instanceof MeprTransaction ) {
            $membership = $arg->get_membership();
            if ( $membership && $membership->ID == 123 ) {
                // Allow the trigger for membership product ID 123
                return true;
            }
        }
    }

    // If not the specific scenario we want to override, return the original value.
    // This ensures the default behavior is maintained unless explicitly changed.
    return $allow_inactive_trigger;
}, 10, 2 );

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

uncanny-automator-pro/src/integrations/memberpress/triggers/mp-usermemexpiresprod.php:102

);
	}

	/**
	 * @param mixed $arg Can be MeprTransaction or MeprEvent depending on which hook fired
	 */
	public function mp_product_expired( $arg ) {
		$allow_inactive_trigger = apply_filters( 'automator_pro_mp_usermemexpiresprod_allow_account_inactive_hook', false, $arg );

		if ( false === $allow_inactive_trigger && current_action() == 'mepr-account-is-inactive' ) {
			return;
		}

		$transaction = null;
		// Handle mepr-account-is-inactive (passes MeprTransaction)

Scroll to Top