Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Dev Docs Example: WooCommerce Memberships simplified programmatic member creation
// Automatically grant membership to a plan at registration
function sv_add_membership_at_registration( $user_id ) {
if ( ! function_exists( 'wc_memberships' ) ) {
$args = array(
// Enter the ID (post ID) of the plan to grant at registration
'plan_id' => 253,
'user_id' => $user_id,
wc_memberships_create_user_membership( $args );
add_action( 'user_register', 'sv_add_membership_at_registration', 15 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.