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

$result = apply_filters(
    'mam_user_roles_after_create_user',
    array $result,     // pass-through accumulator (starts empty)
    int   $user_id
);
Parameter Type Description
$result array Pass-through filter value — an accumulator that starts empty; return it (usually unchanged)
$user_id int The newly-created user’s id

Returns: array — the pass-through $result (typically unchanged). The user id is the second argument, not the filtered value.


Example: persist a custom app-user metadata key

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

        // Persist an app-user-only flag.
        update_user_meta( $user_id, 'my_plugin_signup_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 $result;
    },
    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.
  • The pass-through $result array is the canonical return. Return it (usually unchanged); the user id is the second argument, not the filtered value.
  • No registration payload is passed. Only $user_id reaches your callback — look up any signup context from usermeta or the request yourself.
  • 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
Was this article helpful?
Contents

    Need Support?

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