LLMS_User_Permissions::edit_others_lms_content( bool[] $allcaps, string[] $cap, array $args )

Handle capabilities checks for lms content to allow *editing* content based on course instructor


Parameters Parameters

$allcaps

(bool[]) (Required) Array of key/value pairs where keys represent a capability name and boolean values represent whether the user has that capability.

$cap

(string[]) (Required) Required primitive capabilities for the requested capability.

$args

(array) (Required) Arguments that accompany the requested capability check.

  • (string) Requested capability.
  • '1'
    (int) Concerned user ID.
  • '...$2'
    (mixed) Optional second and further parameters, typically object ID.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/class.llms.user.permissions.php

	public function edit_others_lms_content( $allcaps, $cap, $args ) {

		/**
		 * this might be a problem
		 * this happens when in wp-admin/includes/post.php
		 * when actually creating/updating a course
		 * and no post_id is passed in $args[2].
		 */
		if ( empty( $args[2] ) ) {
			$allcaps[ $cap[0] ] = true;
			return $allcaps;
		}

		$instructor = llms_get_instructor( $args[1] );
		if ( $instructor && $instructor->is_instructor( $args[2] ) ) {
			$allcaps[ $cap[0] ] = true;
		}

		return $allcaps;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.13.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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