Title: conditional hide filter
Last modified: December 12, 2022

---

# conditional hide filter

 *  Resolved [neosan](https://wordpress.org/support/users/nreljed/)
 * (@nreljed)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/conditional-hide-filter/)
 * hello ,
 *     ```
       /**
        * Filter to hide SEO SCcore
        */
       add_filter( 'rank_math/show_score', '__return_false' );
       ```
   
 * I found this code on the [rankmath filter-hooks page](https://rankmath.com/kb/filters-hooks-api-developer/#hide-seo-score)
   
   is it possible to make it more flexible to choose which roles will be excluded
   or included? I would like for example say that the admin and editor roles are
   not affected by the hide
 * thank you`

Viewing 1 replies (of 1 total)

 *  Plugin Support [Rank Math Support](https://wordpress.org/support/users/rankmathteam/)
 * (@rankmathteam)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/conditional-hide-filter/#post-16283675)
 * Hello [@nreljed](https://wordpress.org/support/users/nreljed/),
 * Thank you for contacting the support.
 * You can create an anonymous function, so you are able to add a condition statement
   and check for roles. Please refer to this example code instead:
 *     ```
       add_filter( 'rank_math/show_score', function() {
       	$user = wp_get_current_user();
       	$roles = ( array ) $user->roles;
       	if($roles[0] == 'administrator'){
       		return false;
       	}
   
       	return true;
       } );
       ```
   
 * Hope that helps.

Viewing 1 replies (of 1 total)

The topic ‘conditional hide filter’ is closed to new replies.

 * ![](https://ps.w.org/seo-by-rank-math/assets/icon.svg?rev=3438330)
 * [Rank Math SEO – AI SEO Tools to Dominate SEO Rankings](https://wordpress.org/plugins/seo-by-rank-math/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/seo-by-rank-math/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/seo-by-rank-math/)
 * [Active Topics](https://wordpress.org/support/plugin/seo-by-rank-math/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/seo-by-rank-math/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/seo-by-rank-math/reviews/)

## Tags

 * [add_filter](https://wordpress.org/support/topic-tag/add_filter/)

 * 1 reply
 * 2 participants
 * Last reply from: [Rank Math Support](https://wordpress.org/support/users/rankmathteam/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/conditional-hide-filter/#post-16283675)
 * Status: resolved