WordPress Multisite user activation hook from email

I have created a custom register page which ask for email, username and a membership number of another club.

Before the user is created, I am using an api to check the new user is an existing member of the club, and receiving the id number of that membership record.

I want to store this with the WordPress user, so I am saving it in meta data.

This is a multisite, so am using the following code.

$user_meta = array(‘add_to_blog’ => get_current_blog_id(), ‘new_role’ => ‘subscriber’, ‘club_id’ => $club_id);

wpmu_signup_user($Username, $Email, apply_filters( ‘add_signup_meta’, $user_meta ) );

This all works and I can see my data in the wp_signups table and confirmation email is sent.

Using the Unconfirmed plugin I can also see my new user waiting for confirmation.

I have then set up this so that when the account is confirmed, the club_id is also transferred to the user meta details.

function activate_user($user_id, $password, $meta) {
if (isset($meta[“club_id”]))
update_user_meta( $user_id, “club_id”, $meta[“club_id”]);
}

add_action(‘wpmu_activate_user’,’activate_user’,10,3);

This works as expected if I activate the account using Unconfirmed plugin, but if the user uses the link in the email, it does not. The user is created, all emails send, but the club_id is not stored in the user meta because this hook is not being called.

Is there a way I can get round this?

Read more here:: WordPress Multisite user activation hook from email

Leave a Reply

Your email address will not be published. Required fields are marked *