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.

Can anyone help with this please.



You can do something like this

global $user;

 If($user->your_profile_field_value == 'requiredvalue') {
    Return true;
    Else {
    Return false;
| improve this answer | |
  • thank you @Muhammad Tanweer but how do I get about hiding/showing a block on homepage when block id is lets say '12345'. I've very little experience with php. thanks – ozyy Dec 20 '17 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.