DocsOEngageREST API & Developer Hooks
Developer

REST API & Developer Hooks

OEngageorravo.com/docs/oregister/rest-api-hooks

REST API

Base: /wp-json/oregister/v1/

MethodEndpointAuthDescription
POST/auth/loginNoneLogin with username + password
POST/auth/registerNoneRegister new user
POST/auth/magic-linkNoneRequest magic link email
POST/auth/magic-verifyNoneVerify magic link token
POST/auth/2fa/verifyWP sessionSubmit 2FA code
GET/social/callback/{provider}NoneOAuth callback
GET/profile/{user_id}OptionalPublic profile
PATCH/profileWP authUpdate own profile
GET/gamification/statsWP authXP, level, streak, badges
GET/gamification/leaderboardOptionalTop users
GET/gamification/badgesWP authUser's earned badges

Action Hooks

php// Auth events
add_action( 'oregister_user_registered',    function( int $user_id, string $method ) {} );
add_action( 'oregister_user_logged_in',     function( int $user_id, string $method ) {} );
add_action( 'oregister_login_failed',       function( string $username, string $ip ) {} );
add_action( 'oregister_ip_locked',          function( string $ip, int $duration ) {} );

// Social
add_action( 'oregister_social_linked',      function( int $user_id, string $provider ) {} );
add_action( 'oregister_social_login',       function( int $user_id, string $provider ) {} );

// Gamification
add_action( 'oregister_xp_awarded',         function( int $user_id, int $points, string $event ) {} );
add_action( 'oregister_badge_awarded',       function( int $user_id, string $badge_slug ) {} );
add_action( 'oregister_level_up',            function( int $user_id, int $new_level ) {} );

Filter Hooks

php// Modify XP awarded for an event
add_filter( 'oregister_xp_for_event', function( int $xp, string $event, int $user_id ): int {
    return $xp;
}, 10, 3 );

// Modify badge criteria
add_filter( 'oregister_badge_criteria', function( array $criteria, string $badge_slug ): array {
    return $criteria;
}, 10, 2 );

// Override login redirect URL
add_filter( 'oregister_login_redirect', function( string $url, int $user_id ): string {
    return $url;
}, 10, 2 );

// Add custom social providers
add_filter( 'oregister_social_providers', function( array $providers ): array {
    $providers['discord'] = [ 'label' => 'Discord', 'class' => 'MyDiscordProvider' ];
    return $providers;
} );
REST API & Developer Hooks — OEngage Docs — Orravo