Add access to a blog

This snippet shows how to add access to a blog for a specific user.

function my_threewp_broadcast_get_user_writable_blogs( $action )
{
	$users_and_blogs = [
		// User ID			// Blog IDs
		4				=> [ 4, 5, 10 ],
		6				=> [ 88, 89, 91 ],
	];
	if ( ! isset( $users_and_blogs[ $action->user_id ] ) )
		return;
	
	foreach( $users_and_blogs[ $action->user_id ] as $blog_id )
		$action->add_access( $blog_id );
}
// Broadcast fills the blog list at prio 100, so use a higher number.
add_action( 'threewp_broadcast_get_user_writable_blogs', 'my_threewp_broadcast_get_user_writable_blogs', 200 );