Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_Roles::get_post_type_caps( string $role )
Retrieve the post type specific capabilities for a give role
Description Description
Parameters Parameters
- $role
-
(string) (Required) name of the role
Return Return
(array)
Source Source
File: includes/class.llms.roles.php
private static function get_post_type_caps( $role ) { $caps = array(); // students get nothing if ( 'student' !== $role ) { $post_types = array( 'course' => 'course', 'lesson' => 'lesson', 'llms_quiz' => array( 'quiz', 'quizzes' ), 'llms_question' => 'question', 'llms_membership' => 'membership', ); foreach ( $post_types as $post_type => $names ) { $post_caps = LLMS_Post_Types::get_post_type_caps( $names ); // filter the caps down for these roles if ( in_array( $role, array( 'instructor', 'instructors_assistant' ) ) ) { $allowed = array( 'instructor' => array( 'delete_posts', 'delete_published_posts', 'edit_post', 'edit_posts', 'edit_published_posts', 'publish_posts', 'create_posts', ), 'instructors_assistant' => array( 'edit_post', 'edit_posts', 'edit_published_posts', ), ); foreach ( $post_caps as $post_cap => $cpt_cap ) { if ( ! in_array( $post_cap, $allowed[ $role ] ) ) { unset( $post_caps[ $post_cap ] ); } } } $caps[ $post_type ] = array_fill_keys( array_values( $post_caps ), true ); }// End foreach(). $taxes = array( 'course_cat' => 'course_cat', 'course_difficulty' => array( 'course_difficulty', 'course_difficulties' ), 'course_tag' => 'course_tag', 'course_track' => 'course_track', 'membership_cat' => 'membership_cat', 'membership_tag' => 'membership_tag', ); foreach ( $taxes as $tax => $names ) { $tax_caps = LLMS_Post_Types::get_tax_caps( $names ); // filter the caps down for these roles if ( in_array( $role, array( 'instructor', 'instructors_assistant' ) ) ) { $allowed = array( 'assign_terms', ); foreach ( $tax_caps as $tax_cap => $ct_cap ) { if ( ! in_array( $tax_cap, $allowed ) ) { unset( $tax_caps[ $tax_cap ] ); } } } $caps[ $tax ] = array_fill_keys( array_values( $tax_caps ), true ); } }// End if(). return apply_filters( 'llms_get_' . $role . '_post_type_caps', $caps ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.13.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: