-
Is it possible to show the “admin” tab of a course to an other user roles than only the admin? We have editors or test users which should have the possibility to enroll and delete themselves from a course or reset the statistics or lesson status without the help of the system administrator.
Is there a hook for that?
We are using the logic that if the course is created by any user(He must be an administrator/ Instructor). Only then he can view the admin Tab
If you are using our addon wplms coAuthors Plus. Then you can add multiple Instructors for a single Course and all these instructors can access the admin tab
Refer: https://wplms.io/support/knowledge-base/wplms-coauthor-plus-integration/
Thank you for your tipp. I know that instructors have the possibility to access the course. The point is that I don’t want any editor as an additional instructor (CoAuthor) in every course. These editors would appear in some views too as authors which would look very strange and they also would get any e-mail notifications and so on (same like instructors). I need kind of a 2nd administrator who has the ability to see the admin tab for every course. We edit our courses and lessons centralized from 1-3 editors and don’t use the instructor to handle each course. So is there any hook/program code to achieve that?
I have defined own user roles with a user manager/permission plugin (User Manager Pro for example) but Shop Manager is one of them. Because our Shop Manager is also the editor for courses.
Please try this code and paste it in wp-admin > Plugins > Editor > Select WPLMS Customizer Plugin > wplms-customizer.php
add_filter(‘wplms_course_instructors’,function($authors,$course_id){
if(!is_user_logged_in())
return false;
$user = wp_get_current_user();
if(!empty($user) && !empty($user->roles) && in_array(‘parent’, $user->roles)){
if(empty($authors)){
$authors = array($user->ID);
}else{
$authors[] = $user->ID;
}
}
return $authors;
});
So I pasted the code in WPLMS Customizer and I also tried in the functions.php in the childtheme. As I understood your code, the role “parent” should show me the “admin” tab in the course overview? But after assigning the role to a user, nothing happened. Also the Shop Manager role doesn’t work. Did I get something wrong?
paste this code in wp-admin > Plugins > Editor > Select WPLMS Customizer Plugin > wplms-customizer.php
// Show Admin Tab for shop manager user Role
add_filter(‘wplms_course_instructors’,function($authors){
if(!is_user_logged_in())
return false;
$user = wp_get_current_user();
if(!empty($user) && !empty($user->roles) && in_array(‘shop_manager’, $user->roles)){
if(empty($authors)){
$authors = array($user->ID);
}else{
$authors[] = $user->ID;
}
}
return $authors;
});
sorry, what you posted here and in your thread https://wplms.io/support/knowledge-base/show-admin-tab-for-another-user-role/ (btw. the code has copy paste errors) still doesn’t work for me. I also tried it on the latest theme update on a clean installation but with a user who has shop manager role permission I don’t see the tab “admin” in the front end of a course. I also tried other user roles and changed your code as explained (exchanged ‘shop_manager’ against a different user role).
-
This reply was modified 4 years, 10 months ago by
waytogo.
I have tested the code before sending it to you. Today, again i tested the code and it is showing admin tab on single course page for shop manager user role.
Please share your admin credentials with site URL here in a private reply to check this on your site.
I checked it again in our clean system and now it is working. Strange. I guess in my live system I have some other adaptions which influence from showing it correctly. I will deeply look into it.
-
This reply was modified 4 years, 10 months ago by
The topic ‘How to show course "admin" tab for other user roles than administrator’ is closed to new replies.