Action
uncanny-automator
automator_suremembers_after_access_revoke
Fires after a user's SureMembers access is revoked, passing the user ID and group.
add_action( 'automator_suremembers_after_access_revoke', $callback, 10, 2 );
Description
Fires after SureMembers access is revoked for a user from a specific group. Developers can use this hook to trigger custom actions or automations when a user loses access to a SureMembers group, such as notifying them or updating other user meta. The hook passes the user ID and the specific group ID the access was revoked from.
Usage
add_action( 'automator_suremembers_after_access_revoke', 'your_function_name', 10, 2 );
Parameters
-
$user_id(mixed) - The ID of the user whose access has been revoked.
-
$group(mixed) - This parameter contains the ID of the user whose SureMembers access has been revoked.
Examples
add_action( 'automator_suremembers_after_access_revoke', function( $user_id, $group ) {
// Example: Log when a user is revoked from a SureMembers group.
// This could be used for debugging or for further automation based on revocation.
// Get the user object
$user = get_user_by( 'id', $user_id );
// Ensure the user exists
if ( ! $user ) {
error_log( "automator_suremembers_after_access_revoke: User ID {$user_id} not found." );
return;
}
// Get the group name for logging purposes
// Assuming $group is an object with a 'name' property, adjust if it's just an ID.
$group_name = isset( $group->name ) ? $group->name : $group;
// Log the revocation event
$log_message = sprintf(
'User "%s" (ID: %d) had access revoked from SureMembers group "%s".',
$user->user_login,
$user_id,
$group_name
);
error_log( $log_message );
// --- Further Automation Example ---
// You could trigger other actions here, e.g., sending an email,
// updating a custom field, or interacting with another plugin.
// For example, if you wanted to add a tag to the user in a CRM:
/*
if ( class_exists( 'My_Crm_Integration' ) ) {
$crm = new My_Crm_Integration();
$crm->add_tag( $user_id, 'access-revoked-' . sanitize_title( $group_name ) );
}
*/
}, 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
src/integrations/suremembers/suremembers-integration.php:83
public function after_access_revoke_router( $user_id, $groups ) {
foreach ( $groups as $group ) {
do_action( 'automator_suremembers_after_access_revoke', $user_id, $group );
}
}
Internal Usage
Found in src/integrations/suremembers/triggers/user-removed-from-group.php:39:
$this->add_action( 'automator_suremembers_after_access_revoke', 10, 2 );