LLMS_Prevent_Concurrent_Logins::maybe_prevent_concurrent_logins()

Maybe prevent current logins.


Return Return

(bool) true if concurrent login prevented, false otherwise.


Top ↑

Source Source

File: includes/class-llms-prevent-concurrent-logins.php

	public function maybe_prevent_concurrent_logins() {

		// No logged in user or current user has only one active session: nothing to do.
		if ( empty( $this->user_sessions ) || count( $this->user_sessions ) < 2 ) {
			return false;
		}

		/**
		 * Filters whether or not allowing a specific user to have concurrent sessions.
		 *
		 * @since 5.6.0
		 *
		 * @param bool $allow   Whether or not the user should be allowed to have concurrent sessions.
		 * @param int  $user_id WP_User ID of the current use.
		 */
		if ( (bool) apply_filters( 'llms_allow_user_concurrent_logins', false, $this->user_id ) ) {
			return false;
		}

		// Current user doesn't have any restricted role: nothing to do.
		if ( empty( array_intersect( get_userdata( $this->user_id )->roles, (array) get_option( 'lifterlms_prevent_concurrent_logins_roles', array( 'student' ) ) ) ) ) {
			return false;
		}

		$this->destroy_all_sessions_but_newest();

		return true;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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