Permissions – Allow non-admin to Add xAPI Content

Estimated reading time: < 1 min

If you want to decide whom to allow adding xAPI Content. You can add the following code to your theme’s functions.php file.

And then, use a plugin like User Role Editor, to assign related custom capabilities.

// GrassBlade xAPI
add_filter("gb_xapi_content_post_args", "custom_gb_xapi_content_post_args");
function custom_gb_xapi_content_post_args($cpt_args)
{
$cpt_args['publicly_queryable'] = false;
$cpt_args['show_in_nav_menus'] = false;
$cpt_args['show_in_menu'] = false;
$cpt_args['capability_type'] = 'xapi';
$cpt_args['capabilities'] = array(
'edit_post' => 'edit_xapi',
'read_post' => 'read_xapi',
'delete_post' => 'delete_xapi',
'edit_posts' => 'edit_xapis',
'edit_others_posts' => 'edit_others_xapis',
'publish_posts' => 'publish_xapis',
'read_private_posts' => 'read_private_xapis',
);
return $cpt_args;
}
add_filter("learndash_submenu", "custom_grassblade_learndash_admin_tabs");
function custom_grassblade_learndash_admin_tabs($admin_tabs)
{
if (current_user_can('edit_xapis')) {
$admin_tabs['grassblade']["name"] = __('xAPI Content', "grassblade");
} else {
unset($admin_tabs['grassblade']);
}
return $admin_tabs;
}

Was this article helpful?
Dislike 0 3 of 3 found this article helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *