Function or hook to assign membership

I have made a custom script to capture payment gateway response to add members. i.e
Payment gateway sends me payment response on URL
I add the customer info to Wordpress as "Subscriber" by using their function wp_insert_user().

Now I want to assign the Membership to Subscriber. So this becomes completely automated. Is there any custom function call or hook for that purpose ?

  • Predrag Dubajic
    • Support

    Hey @Hassan,

    Hope you're doing well today :slight_smile:

    Thanks for your question, it's great to hear when our users are so creative. I must say that this is a bit beyond my knowledge of coding so I am tagging an available developer from second level support line in this thread for his valuable opinion on this issue. Please note that, developer response might be slower than usual staff response, so we appreciate your patience on this.

    You could also post a job in our job board where you can hire a developer to assist further:
    Please note that, no WPMU official staff members are allowed to work in the job board.

    Best regards,

  • Hoang Ngo
    • Code Slayer

    Hey @Hassan,

    I hope you are well today.

    For assigning a member to a subscription, you can use this code
    The variable $membership_id is the ID of the subscription you want to assign user to.
    The $user_id is the ID of the user you want to have the membership.

    If you have any issues please don't hesitate to let us know so we can assist

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.