• Resolved neosan

    (@nreljed)


    hello ,

    /**
     * Filter to hide SEO SCcore
     */
    add_filter( 'rank_math/show_score', '__return_false' );

    I found this code on the rankmath filter-hooks page
    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

    (@rankmathteam)

    Hello @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.