shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Restrict instructors from creating course, lesson and topic categories

We have received frequent queries from our customers requesting to allow instructors to only set category for a course, lesson or topic from the already existing list and restrict the instructors from creating new ones.

The following is a code snippet that you can make use of to hide the links to create new category for a course, lesson and topic for instructors.

You can make use of the code snippet by either of the following ways

  • Your child theme’s functions.php file
  • Make use of the Code Snippets add-on
<?php
if (! function_exists('ir_custom_hide_category_links')) {
    /**
     * Hide the new category creation links for instructors
     *
     * @author Kumar Rajpurohit <[email protected]>
     */
    function ir_custom_hide_category_links() {
        if (! function_exists('wdm_is_instructor') || ! wdm_is_instructor()) {
            return;
        }
        global $current_screen;

        $allowed_screens = array(
            'sfwd-lessons',
            'sfwd-courses',
			'sfwd-topic'
        );

        // Check if course or lesson edit screen.
        if ( empty( $current_screen ) || ! in_array( $current_screen->id, $allowed_screens ) ) {
            return;
        }
        ?>
        <style>
        /* Hide instructor category adding link */
        .components-button.editor-post-taxonomies__hierarchical-terms-add.is-link {
            display: none;
        }
        </style>
        <?php
    }
    add_action('admin_head', 'ir_custom_hide_category_links');
}
?>
Updated on August 10, 2020
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Was this article helpful?

shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Related Articles