Hook: mam_user_roles_after_create_user

Purpose

Fires after mam_user_roles_manager finishes creating a user via the mam-main registration flow. Use it for post-registration cleanup — persist app-user metadata, queue welcome flows, sync with external systems.

Distinct from WP’s native user_register action: this fires only when the user was created through mam-main (not through wp-admin → Users → Add New, for example).


Signature

$user_id = apply_filters(
    'mam_user_roles_after_create_user',
    int   $user_id,
    array $registration_data
);
Parameter Type Description
$user_id int The newly-created user’s id
$registration_data array The submitted registration data (email, role, custom fields)

Returns: int — the user id (typically unchanged).


Example: persist a custom app-user metadata key

add_filter( 'mam_user_roles_after_create_user',
    function ( int $user_id, array $registration_data ): int {

        // Persist an app-user-only flag.
        update_user_meta( $user_id, 'my_plugin_signup_source', $registration_data['source'] ?? 'app' );

        // Trigger a downstream side effect.
        do_action( 'mam_notification_send_message', array(
            'message_type' => 'mam-my-plugin-welcome_email',
            'recipient_id' => $user_id,
        ) );

        return $user_id;
    },
    10, 2
);

Hook When
mam_before_login_start Before login validation begins
mam_user_logged_in After successful login
mam_user_roles_before_create_user Pre-create payload mutation
mam_user_roles_before_create_user_args Pre-create args mutation
mam_user_roles_after_create_user (this) Post-create cleanup
mam_new_user_added_complete Action variant — after the entire registration flow finishes
mam_update_current_user After current-user state changes
mam_after_update_user_profile After profile update completes
mam_user_roles_delete_user Pre-delete-user veto + cleanup
mam_user_roles_modify_user_profile_values_before_save Last-chance edit of profile values pre-save
mam_user_roles_save_addl_user_profile_field_{key} Per-field custom save logic

Gotchas

  • Fires only for mam-main registrations. WP-admin user creation doesn’t fire this. If you need to handle every user creation, hook WP’s user_register instead.
  • $user_id is the canonical return. Don’t return anything else — downstream subscribers expect an int.
  • $registration_data shape varies by registration path (email signup, social, magic-link, phone-code). Defensively check keys.
  • The bundled welcome email fires from the registration flow itself via mam-user-roles-welcome_email. Don’t double-send by firing the same notification from this filter.

  • Recipe: Customize onboarding
  • Hook: mam_user_logged_in
  • Hook: mam_add_fields_to_user_profile
  • Hook: mam_user_roles_save_addl_user_profilefield{key}
  • Hook: mam_notification_send_message

Metadata

Field Value
Article type Hook Reference
Plugin slug mam-main
Applies to plugin version 2.1.11+
Hook type filter
Audience PHP developer
Last verified 2026-05-02
Contents

    Need Support?

    Can’t find the answer you’re looking for? Don’t worry we’re here to help!