Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thanks @sumon1068, I got this link after searching a lot, I did all things to hide categories in admin none of the plugin are working now for this function and finally.
    I made some modifications for those who want to use id instead of slug

    function hide_categories_for_specific_user( $exclusions, $args ){
    if ( ((defined( ‘REST_REQUEST’ ) && REST_REQUEST) or $GLOBALS[‘pagenow’] === ‘edit.php’ ) && !current_user_can( ‘manage_options’ ) ) {
    // IDs of terms to be excluded
    $exclude_array = array(“12″,”16″,”17”); // CHANGE THIS TO IDs OF YOUR TERMS
    // Generation of exclusion SQL code
    $exterms = wp_parse_id_list( $exclude_array );
    foreach ( $exterms as $exterm ) {
    if ( empty($exclusions) )
    $exclusions = ‘ AND ( t.term_id <> ‘ . intval($exterm) . ‘ ‘;
    else
    $exclusions .= ‘ AND t.term_id <> ‘ . intval($exterm) . ‘ ‘;
    }
    // Closing bracket
    if ( !empty($exclusions) )
    $exclusions .= ‘)’;
    // Return our SQL statement
    }
    return $exclusions;
    }

    // Finally hook up our filter
    add_filter( ‘list_terms_exclusions’, ‘hide_categories_for_specific_user’, 10, 2 );`

Viewing 1 replies (of 1 total)