Allow LearnDash group leaders to add and edit H5P content

Written by Mark Langdale

9 July 2022

LearnDash and H5P are two plugins that work together brilliantly to deliver a rich and engaging user experience.

We recently posted a video to our YouTube channel that shows you How to allow Group Leaders to do more in your LearnDash LMS.

This had a great follow up question from someone who wanted to allow group leaders to edit H5P content.

If you want to allow your LearnDash group leaders to be able to add and edit H5P content, then this is can be achieved by adding the following code to your theme’s functions.php file:

function allow_group_leader_h5p_access(){
$group_leader_role = get_role( 'group_leader' );
$group_leader_role->add_cap( 'view_h5p_contents' );
$group_leader_role->add_cap('edit_h5p_contents' );
$group_leader_role->add_cap( 'view_others_h5p_contents' );
$group_leader_role->add_cap( 'edit_others_h5p_contents' );
}
add_action('admin_init','allow_group_leader_h5p_access');

This will give LearnDash’s group leader role the following capabilities, but you can remove some of these based on your requirements:

  • view_h5p_contents – Allows the user to view a list of their own H5P content in the WordPress backend
  • edit_h5p_contents – Allows the user to edit their own H5P content
  • view_others_h5p_contents – Allows the user to view other people’s H5P content in the WordPress backend
  • edit_others_h5p_contents – Allows the user to edit other people’s H5P content

Don’t have access to your theme to make this change? You should be able to achieve similar by enabling the capabilities above on the group leader role using a plugin like User Role Editor.

We hope you find this useful in your LearnDash / H5P projects.

.

0 Comments

Submit a Comment

Your email address will not be published.

Other blog posts you may be interested in…

LearnDash Cloud Unwrapped

LearnDash Cloud Unwrapped

In this video we’re taking a detailed look at LearnDash Cloud - the new hosted course solution from LearnDash. We’ve...