Skip to content

Instantly share code, notes, and snippets.

@codename065
Last active June 28, 2023 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codename065/d12a38a7fc5e354afa08853b716ff20b to your computer and use it in GitHub Desktop.
Save codename065/d12a38a7fc5e354afa08853b716ff20b to your computer and use it in GitHub Desktop.
hide category when user does not have access
<?php
add_filter("get_terms", function ($terms, $tax, $ta, $tz){
$_terms = [];
if($tax[0] === 'wpdmcategory') {
foreach ($terms as $term) {
if(WPDM()->categories::userHasAccess($term->term_id)) {
$_terms[] = $term;
}
}
}
return $_terms;
}, 10, 4);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment