Can’t add user to blog on registration (Multisite)

Regarding the update part in your question:

I think the problem here is that you’re missing the number of accepted arguments in your add_action() setup.

If you check out the Codex, the usage is:

add_action( $hook, $function_to_add, $priority, $accepted_args );

where by default $priority = 10 and $accepted_args = 1.

So your code snippet should be like:

add_action ( 'wpmu_activate_user', 'assign_user_to_blog', 10, 3 );

function assign_user_to_blog( $user_id, $password, $meta )
{
    $role = isset( $meta['role'] ) ? $meta['role'] : 'dmd';
    add_user_to_blog( 3, $user_id, $role );
}

but the $meta variable is undefined in your previous code snippet.

When developing you should remember to use WP_DEBUG to watch for PHP errors, warnings and notices. Check for example the Debugging in WordPress in the Codex.

Leave a Comment