Install::roles_and_permissions()
Set Default roles and permission during DozentLMS activation
Description
Example usage:
roles_and_permissions();
See also
Source
File: classes/Install.php
public static function roles_and_permissions() { $instructor_role = DOZENT_INSTRUCTOR_ROLE; $permissions = [ //Manage Instructor 'dozent_instructor', //Posts Type Permission 'edit_course', 'read_course', 'delete_course', 'delete_courses', 'edit_courses', 'edit_others_courses', 'read_private_courses', ]; remove_role( $instructor_role ); add_role( $instructor_role, DOZENT_INSTRUCTOR_ROLE_NAME, $permissions ); $instructor = get_role( $instructor_role ); if ( $instructor ) { $instructor_cap = array( 'edit_posts', 'read', 'upload_files', ); $instructor_cap = array_merge( $instructor_cap, $permissions ); $can_publish_course = (bool) dozent_get_option( 'instructor_can_publish_course' ); if ( $can_publish_course ) { $instructor_cap[] = 'publish_courses'; } foreach ( $instructor_cap as $cap ) { $instructor->add_cap( $cap ); } } $administrator = get_role( 'administrator' ); if ( $administrator ) { $permissions[] = 'publish_courses'; foreach ( $permissions as $cap ) { $administrator->add_cap( $cap ); } } /** * Add Instructor role to administrator */ if ( current_user_can( 'administrator' ) ) { dozent_instructor_approve( get_current_user_id() ); } }
Changelog
Version | Description |
---|---|
DozentLMS 1.0.0 | Introduced. |