llms_can_user_bypass_restrictions( LLMS_Student|WP_User|int $user = null, integer $post_id = null )

Determines whether or not a user can bypass enrollment, drip, and prerequisite restrictions.


Parameters Parameters

$user

(LLMS_Student|WP_User|int) (Optional) LLMS_Student, WP_User, or WP User ID, if none supplied get_current_user() will be used.

Default value: null

$post_id

(integer) (Optional) A WP_Post ID to check permissions against. If supplied, in addition to the user's role being allowed to bypass the restrictions, the user must also have edit_post capabilities for the requested post.

Default value: null


Top ↑

Return Return

(boolean)


Top ↑

Source Source

File: includes/functions/llms.functions.person.php

function llms_can_user_bypass_restrictions( $user = null, $post_id = null ) {

	$user = llms_get_student( $user );

	if ( ! $user ) {
		return false;
	}

	$roles = get_option( 'llms_grant_site_access', '' );
	if ( ! $roles ) {
		$roles = array();
	}

	if ( ! array_intersect( $user->get_user()->roles, $roles ) ) {
		return false;
	}

	if ( $post_id && ! user_can( $user->get( 'id' ), 'edit_post', $post_id ) ) {
		return false;
	}

	return true;

}


Top ↑

Changelog Changelog

Changelog
Version Description
5.9.0 Added optional second parameter $post_id.
3.9.0 Unknown.
3.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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