Display block on certain page

I want to display a block on the user/* page. I checked "only the listed pages" and entered "user/" but the block also appears on "user//relationships" for example.

How can I keep the block on just the first path?

• "Just the first path" is which path? user/* is supposed to show all pages such as user/relationships /user/mycustompath etc., because * is a wildcard. Where exactly do you want to show the block? – Patrick Kenny Feb 7 '13 at 2:30
• Just on the individual user's profiles, and not on the accompanying tabs associated with it. – rborgeous Feb 7 '13 at 3:13
• @user12763, you copied my code into your question. This is not irrelevant. Thus, I edited your question to get it back to the original state. I wonder why you did not understand what I said in the code: && you may add more conditions here by checking arg(1), arg(2) which is what you are trying to achieve. – Sithu Feb 14 '13 at 5:28

If you want more control on this, you can choose the option "Pages on which this PHP code returns TRUE (experts only)" and you can write the following similar code snippet the the box.

<?php
if( arg(0) == 'user' /* && you may add more conditions here by checking arg(1), arg(2) */) {
return TRUE; // will display the block
}
return FALSE; // will not display the block
?>


The alternative way is to check the path with regular expression:

<?php
if( preg_match('/^user\/[[:digit:]]\$/', current_path()) ) {
return TRUE; // will display the block
}
return FALSE; // will not display the block
?>


This will show your block only at the path user/*.

• I tried it out and is still displays on user/*/edit i just want it on the user's main profile. nothing else. – rborgeous Feb 14 '13 at 0:56

Check "Pages on which this PHP code returns TRUE (experts only) in block settings" and paste:

<?php
if ((arg(0) == 'user') && is_numeric(arg(1)) && (arg(2) == NULL)) {
return TRUE;
}
else {
return FALSE;
}
?>

• This is what I mentioned in my answer - arg(0) == 'user' /* && you may add more conditions here by checking arg(1), arg(2) */ :) – Sithu Feb 14 '13 at 2:55