Smart Members fires actions when memberships change and runs filters before it decides who gets in. Every hook is prefixed smartmembers_ and used with add_action() or add_filter().

Help, Features in Smart Members showing the Developers rows: PHP API to grant, revoke and read grants, and hooks to add events to a member's activity log, both included in Core
Help → Features lists the hooks as a Core feature.

All ship in the free plugin except the Pro only group. Admin-screen hooks are left out because they change between releases. To list every hook in your version:

grep -rn "do_action\|apply_filters" smartmembers/app smartmembers-pro/app | grep "smartmembers_"

Grant, UserGrant, AccessResult and AccessGroup are described in Access API: grant, revoke and read.

Membership lifecycle

// Actions. They fire after the change and cannot stop it.
smartmembers_access_granted       ( Grant $grant, int $user_id, int $access_group_id, array $context )
    // any grant written or reactivated; emails, role sync and Pro integrations listen here
smartmembers_access_revoked       ( Grant $grant, int $user_id, int $access_group_id, array $context )
    // $context['reason'] says why: 'expired' (with source 'expiry') when the end date passed;
    // $context['quiet'] is true when it passed more than two days earlier (no email)
smartmembers_access_paused        ( Grant $grant )
smartmembers_grant_status_changed ( UserGrant $grant, string $new_status, string $old_status )
smartmembers_user_blocked         ( int $user_id, int $actor )   // grants are kept
smartmembers_user_unblocked       ( int $user_id )
smartmembers_access_group_saved   ( int $group_id, AccessGroup $group )
smartmembers_access_group_deleted ( int $group_id )
smartmembers_access_rules_saved   ( array $rules )
smartmembers_download_served      ( int $attachment_id, int $user_id )   // just before the file is sent
add_action( 'smartmembers_access_revoked', function ( $grant, $user_id, $group_id, $context ) {
    if ( ! empty( $context['quiet'] ) ) {
        return; // Old backlog, not news.
    }
    if ( 673 === (int) $group_id ) { // AI Weekly — Pro
        wp_mail( 'sam@aiweekly.example', 'Pro member left', "User {$user_id}: {$context['reason']}" );
    }
}, 10, 4 );

Before a grant is written

// Filters. Return a different value to change or stop the grant.
smartmembers_should_grant              ( bool $allow, int $user_id, int $access_group_id, array $context )
    // false vetoes: the call returns grant_vetoed and the plugin log records it
smartmembers_grant_expiry              ( ?string $expires_at, null $grant, array $context )
smartmembers_may_reactivate_grant      ( bool $may, UserGrant $grant, string $owner, array $context )
    // by default only the source that revoked a grant may revive it
smartmembers_registration_grant_groups ( int[] $groups, int $user_id )
smartmembers_user_grants               ( array $grants, int $user_id )   // extra grants from elsewhere
smartmembers_role_sync_enabled         ( bool $enabled )
// Only staff email addresses may join AI Weekly — Pro from code or checkout.
add_filter( 'smartmembers_should_grant', function ( $allow, $user_id, $group_id, $context ) {
    if ( 673 === (int) $group_id && 'woocommerce' !== $context['source'] ) {
        $email = get_userdata( $user_id )->user_email;
        return str_ends_with( $email, '@aiweekly.example' ) ? $allow : false;
    }
    return $allow;
}, 10, 4 );

Restriction and refusal

smartmembers_user_can_access       ( bool $can, int $user_id, int|string $object_id, string $reason, AccessResult $result )
smartmembers_bypass_restrictions   ( bool $bypass, int $user_id, string $object_type, int|string $object_id )
    // also asked for menu items, with $object_type 'menu_item'
smartmembers_hidden_post_ids       ( int[] $hidden, int $user_id )
smartmembers_restriction_message   ( string $html, int $object_id, string $reason, AccessResult $result )
smartmembers_restriction_redirect  ( string $target, AccessResult $result )
smartmembers_access_next_step      ( array $step {url, text}, AccessResult $result, ?WP_Post $post, ?array $rule )
smartmembers_access_group_names    ( string[] $names, int[] $groups )
smartmembers_drip_unlock_date      ( ?int $unlock, ?array $grant, Rule $rule )   // Unix time; null = now
smartmembers_compiled_access_rules ( array $rules )   // add your own rule types
smartmembers_product_is_restricted ( bool $restricted, int $product_id, int $user_id )
smartmembers_show_protected_column ( bool $show, string $post_type )
smartmembers_post_types_args       ( array $args )   // get_post_types() arguments for the group editor
smartmembers_post_types_excludes   ( array $excludes, string $context )   // default 'attachment'
// Add a line under every refusal for readers who arrived from the newsletter.
add_filter( 'smartmembers_restriction_message', function ( $html, $object_id, $reason, $result ) {
    if ( 'logged_out' === $reason ) {
        $html .= '<p>Already subscribed to AI Weekly? <a href="/login/">Log in</a>.</p>';
    }
    return $html;
}, 10, 4 );
A Deep Dive post on the AI Weekly site as a visitor sees it, with the members-only message and a Get AI Weekly — Reader button
smartmembers_restriction_message changes the message; smartmembers_access_next_step changes the button.

Members and the member area

// Filters
smartmembers_member_activity          ( array $events, int $user_id )
    // append events with at (MySQL datetime), type, label; optional detail, group_id,
    // group_name, actor_name. Events without 'at' are dropped.
smartmembers_user_is_member           ( bool $is_member, WP_User $user )   // cannot make staff members
smartmembers_may_view_member_area     ( bool $may, int $user_id )
smartmembers_member_content           ( array $items, int $user_id )
smartmembers_list_members             ( WP_User[] $users, int[] $group_ids, array $args )   // Member Directory block
smartmembers_may_upload_avatar        ( bool $may, int $user_id )
smartmembers_registration_open        ( bool $open )   // default: WordPress's own setting
smartmembers_disposable_email_domains ( string[] $domains )

// Actions
smartmembers_member_area_sections         ( int $user_id )   // print extra dashboard sections
smartmembers_after_user_registration      ( int $user_id, int $member_id, array $data )
smartmembers_after_logged_in_user_register()
smartmembers_after_personal_info_update   ( int $user_id, int $member_id )
smartmembers_after_address_update         ( int $user_id, int $member_id )
smartmembers_after_preferences_update     ( int $user_id, int $member_id )
smartmembers_after_password_update        ( int $user_id )
smartmembers_after_avatar_upload          ( int $user_id, int $attachment_id )
smartmembers_after_avatar_remove          ( int $user_id )
smartmembers_personal_data_erased         ( int $user_id, int $removed, bool $anonymised )
smartmembers_history_trimmed              ( int $removed, int $days )
// Show newsletter opens from your own table in the member's Activity timeline.
add_filter( 'smartmembers_member_activity', function ( $events, $user_id ) {
    foreach ( my_newsletter_opens( $user_id ) as $open ) {
        $events[] = array(
            'at'     => $open->opened_at,      // site timezone, 'Y-m-d H:i:s'
            'type'   => 'newsletter_open',
            'label'  => 'Opened newsletter',
            'detail' => $open->issue_title,
        );
    }
    return $events;
}, 10, 2 );
The Activity panel on Rosa Iqbal's member page listing access granted, account registered and access starts events
Events added through smartmembers_member_activity appear here, in date order.

Emails, WooCommerce and integrations

// Emails
smartmembers_lifecycle_email       ( array $mail {subject, body}, string $which, int $user_id )
    // $which: 'granted' | 'expiring' | 'revoked'
smartmembers_defer_lifecycle_email ( bool $defer, string $which, int $user_id )   // false sends at once
smartmembers_email_headers         ( array|string $headers )

// WooCommerce and integrations
smartmembers_woocommerce_grant_pending              ( int $order_id, string $email, int[] $group_ids )   // action
smartmembers_woocommerce_link_guest_orders_by_email ( bool $allow, WC_Order $order, string $email )
smartmembers_woocommerce_may_reactivate             ( bool $may, UserGrant $grant, string $owner )
smartmembers_woocommerce_product_map_updated        ( int $product_id, int[] $group_ids )   // action
smartmembers_woocommerce_reconciled                 ( array $summary )   // action, daily
    // $summary: checked, in_sync, drift, missing, held
smartmembers_package_sources                        ( array $sources )
smartmembers_integrations                           ( array $integrations )   // add an Integrations card
smartmembers_integration_active_by_default          ( bool $active, string $slug )
smartmembers_integration_dependency_met             ( bool $met, array $integration )
smartmembers_integrations_loaded                    ()   // action
smartmembers_integration_{slug}_loaded              ()   // action

Pro only

Pro: These fire only while Smart Members Pro is running with a licence.

smartmembers_audience_event          ( AudienceEvent|null $event )   // null sends nothing to Mailchimp, MailerLite,
                                                                     // FluentCRM, Zapier or Pabbly
smartmembers_audience_providers      ( array $providers )   // register an AudienceProvider
smartmembers_audience_error          ( string $slug, AudienceEvent $event, Throwable $e )   // action
smartmembers_fluentcrm_tag_title     ( string $title, string $group_name )
smartmembers_members_area_sections   ( array $sections, int $user_id )
smartmembers_new_role_capabilities   ( array $capabilities, string $slug )
smartmembers_plan_display_price      ( PlanPrice|array|null $price, object $plan )
smartmembers_pro_local_licence_bypass( bool $is_local )   // false shows the unlicensed state locally
// Send only paid memberships to your email tools.
add_filter( 'smartmembers_audience_event', function ( $event ) {
    return 'registration' === $event->source ? null : $event;
} );

Loading, settings and feature checks

smartmembers_loaded                  ()   // action, on plugins_loaded, before modules boot
smartmembers_init                    ()   // action, on init
smartmembers_database_upgraded       ( string $from, string $to )   // action
smartmembers_capability_available    ( bool $available, string $slug, string $tier )
smartmembers_settings_tab_saved      ( string $tab, array $clean )   // action
smartmembers_login_url_bypass        ( bool $bypass )   // let one request reach wp-login.php
smartmembers_login_customizer_config ( array $config )
smartmembers_dashboard_tiles         ( array $tiles )

Writing callbacks that behave

  • Ask for the arguments. Lifecycle hooks pass four; add 10, 4 or you get only the first.
  • Keep lifecycle callbacks fast. They run inside the request, so a checkout waits. Schedule slow work with wp_schedule_single_event().
  • Avoid queries in access filters. They can run many times per page.
  • Staff bypass restriction. Test logged out or as a member.
  • Expiry arrives within the hour, through smartmembers_access_revoked with reason expired.
  • No "about to expire" action. Reword the expiring email with smartmembers_lifecycle_email.

Related articles