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.

add_filter("gb_xapi_content_post_args", "custom_gb_xapi_content_post_args");

function custom_gb_xapi_content_post_args($cpt_args){
    $cpt_args['show_in_menu'] = true;
    $cpt_args['capability_type'] = 'xapi';
    $cpt_args['map_meta_cap'] = true;
    $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",
       'read'                   => "read",
       'delete_posts'           => "delete_xapis",
       'delete_private_posts'   => "delete_private_xapis",
       'delete_published_posts' => "delete_published_xapis",
       'delete_others_posts'    => "delete_others_xapis",
       'edit_private_posts'     => "edit_private_xapis",
       'edit_published_posts'   => "edit_published_xapis",
       'create_posts'           => "edit_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 5 of 5 found this article helpful.

Leave a Reply

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

Shopping Cart
Scroll to Top
We are making major changes on payment options & license management. Please, click here to report any issues you face during the purchase.