• Resolved jjttey

    (@jjttey)


    I am using MemberPress plugin to manage different memberships for different users. When I call the /auth endpoint to get a JWT, I want this JWT info to also include the active memberships of the logged-in user.

    Is this possible? How would I go about implementing this? Any example code snippets to achieve this would be really helpful.

    Thanks so much!

Viewing 1 replies (of 1 total)
  • Plugin Author Nicu Micle

    (@nicu_m)

    Hello @jjttey,

    There is a hook that allows you to add custom data in the JWT payload: simple_jwt_login_jwt_payload_auth. This hook is called on /auth endpoint. Here you can modify payload parameters.

    Here is an example:

    
     add_filter('simple_jwt_login_no_redirect_message',function($payload, $request){
        $payload['myvalue'] = 'somevalue';
    
        return $payload;
    },10, 2);
    

    Let me know if this works for you.

    PS: please don’t forget to rate this plugin and spread the word about it.

    Best regards,
    Nicu.

Viewing 1 replies (of 1 total)

The topic ‘Custom data in JWT payload for Authentication’ is closed to new replies.