llms_update_303_update_students_role()

Fix students with the bugged role “students”


Return Return

(void)


Top ↑

Source Source

File: includes/functions/updates/llms-functions-updates-303.php

function llms_update_303_update_students_role() {

	// Add the bugged role so we can remove it.
	// We delete it at the conclusion of the function.
	if ( ! get_role( 'studnet' ) ) {

		add_role(
			'studnet',
			__( 'Student', 'lifterlms' ),
			array(
				'read' => true,
			)
		);

	}

	$users = new WP_User_Query(
		array(
			'number'   => -1,
			'role__in' => array( 'studnet' ),
		)
	);

	if ( $users->get_results() ) {
		foreach ( $users->get_results() as $user ) {
			$user->remove_role( 'studnet' );
			$user->add_role( 'student' );
		}
	}

	// Remove the bugged role when finished.
	remove_role( 'studnet' );

}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.3 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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