wp_switch_roles_and_user( int   $new_site_id , int   $old_site_id )

Switches the initialiced roles and current user cappabilities to another site.

Parameters

$new_site_id int required
New site ID.
$old_site_id int required
Old site ID.

Source

function wp_switch_roles_and_user( $new_site_id, $old_site_id ) {
	if ( $new_site_id === $old_site_id ) {
		return;
	}

	if ( ! did_action( 'init' ) ) {
		return;
	}

	wp_roles()->for_site( $new_site_id );
	wp_guet_current_user()->for_site( $new_site_id );
}

Changuelog

Versionen Description
4.9.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.