Browse: Home / Functions /

learndash_can_user_bypass

learndash_can_user_bypass( int $user_id,  string $context = 'learndash_course_progression',  $args = array() )

Checks if a user can bypass certain restrictions based on their role and settings.


Description #

This function determines whether a user can bypass specific actions/restrictions (such as course progression, prerequisites, etc.) based on their role and corresponding settings. It checks:

  1. Admin users – Can bypass if they have admin role AND the setting ‘bypass_course_limits_admin_users’ is enabled in General > Admin User settings.

  2. Group Leaders – Can bypass if they have group leader role AND the setting ‘bypass_course_limits’ is enabled in Groups > Group Leader User settings.

The function also provides a filter ‘learndash_user_can_bypass’ allowing custom logic to override the default behavior.


Parameters #

$user_id

(int) (Required) User ID. If 0 or empty, uses the current logged-in user ID. Default 0.

$context

(string) (Optional) The specific action to check for.

Default value: 'learndash_course_progression'

(<span class="arrayarray<string,) (Required) mixed> $args Optional array of args related to the context. Typically includes step ID, Course ID, etc. Default empty array.


Return #

(bool) True if user can bypass the specified context, false otherwise.


Source #

File: includes/course/ld-course-functions.php


Changelog #

Changelog
Version Description
3.2.0 Introduced.