Skip to main content
added 76 characters in body
Source Link
Milo
  • 78.9k
  • 4
  • 127
  • 168

Filters are for modifying data that's passed through them. You need to take the input, modify it, then return it.

function exclude_not_allowed_terms( $args, $taxonomies ) {
    if(!current_user_can('edit_others_posts')
      && in_array( 'my-taxonomy', $taxonomies ) ) {
        $args['meta_query'] = array(
            array(
                'key'    => 'owner',
                'value'  => get_current_user_id()
            )
        );
    }
    return $args;
}
add_filter( 'get_terms_defaults','exclude_not_allowed_terms', 20, 2 );

Filters are for modifying data that's passed through them. You need to take the input, modify it, then return it.

function exclude_not_allowed_terms( $args ) {
    if(!current_user_can('edit_others_posts')) {
        $args['meta_query'] = array(
            array(
                'key'    => 'owner',
                'value'  => get_current_user_id()
            )
        );
    }
    return $args;
}
add_filter('get_terms_defaults','exclude_not_allowed_terms');

Filters are for modifying data that's passed through them. You need to take the input, modify it, then return it.

function exclude_not_allowed_terms( $args, $taxonomies ) {
    if(!current_user_can('edit_others_posts')
      && in_array( 'my-taxonomy', $taxonomies ) ) {
        $args['meta_query'] = array(
            array(
                'key'    => 'owner',
                'value'  => get_current_user_id()
            )
        );
    }
    return $args;
}
add_filter( 'get_terms_defaults','exclude_not_allowed_terms', 20, 2 );
added 51 characters in body
Source Link
Milo
  • 78.9k
  • 4
  • 127
  • 168

Filters are for modifying data that's passed through them. You need to take the input, modify it, then return it.

function exclude_not_allowed_terms( $args ) {
    if(!current_user_can('edit_others_posts')) {
        $args['meta_query'] = array(
            'key'array(
                'key'    => 'owner',
            'value'    'value'  => get_current_user_id()
            )
        );
    }
    return $args;
}
add_filter('get_terms_defaults','exclude_not_allowed_terms');

Filters are for modifying data that's passed through them. You need to take the input, modify it, then return it.

function exclude_not_allowed_terms( $args ) {
    if(!current_user_can('edit_others_posts')) {
        $args['meta_query'] = array(
            'key'       => 'owner',
            'value'     => get_current_user_id()
        );
    }
    return $args;
}
add_filter('get_terms_defaults','exclude_not_allowed_terms');

Filters are for modifying data that's passed through them. You need to take the input, modify it, then return it.

function exclude_not_allowed_terms( $args ) {
    if(!current_user_can('edit_others_posts')) {
        $args['meta_query'] = array(
            array(
                'key'    => 'owner',
                'value'  => get_current_user_id()
            )
        );
    }
    return $args;
}
add_filter('get_terms_defaults','exclude_not_allowed_terms');
Source Link
Milo
  • 78.9k
  • 4
  • 127
  • 168

Filters are for modifying data that's passed through them. You need to take the input, modify it, then return it.

function exclude_not_allowed_terms( $args ) {
    if(!current_user_can('edit_others_posts')) {
        $args['meta_query'] = array(
            'key'       => 'owner',
            'value'     => get_current_user_id()
        );
    }
    return $args;
}
add_filter('get_terms_defaults','exclude_not_allowed_terms');