how to display/hide block on homepage depending the value in user profile field? I'm currently displaying a block on my D7 site' homepage.

Now I've a requirement to display that block only if the logged in user has a specific value in their profile.

I know it can be done using php evaluation by navigating to the bottom of the block and then click (Pages > Pages on which this PHP code returns TRUE ) but have no experience in writing php scripts.

global $user;

If($user-&gt;your_profile_field_value == 'requiredvalue') 
{ 
// display the block 
// display the block only on 'homepage' } 
Else { // don't display the block }


I'm new to php can someone please help me fill in the blanks in above code snippet.

thanks
I would use the PHP visibility settings to display the block if user has requiredvalue. Once you've created the block that you want to display (or not display) add the following code to the "Page specific visibility settings" in the block configuration menu:

 &lt;?php 
    global $user;

    If($user-&gt;your_profile_field_value == 'requiredvalue' &amp;&amp; drupal_is_front_page()) {
    return TRUE;
    }

    return FALSE;

    ?&gt;