Skip to:
Content
Pages
Categories
Search
Top
Bottom

hide css element for bp displayed user id (role)


  • entoen
    Participant

    @kamerhuren

    hi, i am trying to hide a css element for a specific role of the displayed user. for now it is not working. i need some help.

    <?php
    add_action( 'wp_head', 'get_user_role' );
    function get_user_role() {
    	
    	// Get Current User Data.
        $user = get_userdata( bp_displayed_user_id() );
    
        // Get Roles.
        $roles = (array) $user->roles;
    	
    	$user_role = array_shift($user_roles);
    	if ($user_role == "editor"){
    	?>
    	<style type="text/css">#qa-52778a {display: none!important;}</style>
    	<?php
    
    	};
    };
    
  • You must be logged in to reply to this topic.
Skip to toolbar