LLMS_REST_API_Key::has_permission( string $method )

Determine if the key has the permissions required by the HTTP Request Method.


Parameters Parameters

$method

(string) (Required) The HTTP request method.


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/models/class-llms-rest-api-key.php

	public function has_permission( $method ) {

		$permissions = $this->get( 'permissions' );

		switch ( $method ) {
			case 'HEAD':
			case 'GET':
				$ret = ( 'read' === $permissions || 'read_write' === $permissions );
				break;

			case 'POST':
			case 'PUT':
			case 'PATCH':
			case 'DELETE':
				$ret = ( 'write' === $permissions || 'read_write' === $permissions );
				break;

			case 'OPTIONS':
				$ret = true;
				break;

			default:
				$ret = false;

		}

		return $ret;

	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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