I want to show a block on a member's profile page (member/*) but not on member/*/likes.

It doesn't seem I can do this without PHP in the block settings, does it?

2 Answers 2


Try restricting visibility to this URI:


(trailing slash!)

Alternatively, you can download the Context module and position the block using a new context, and negate the member/*/likes path in your context configuration.

  • I had tried member/*/ but then it wouldn't show on a member/user123 page
    – uwe
    Mar 6, 2013 at 6:11
  • Grab the Context module - it'll do what you're after easily enough! Mar 6, 2013 at 17:43

There is a way to answer your question without PHP in the block settings (as in your question): you can use the Rules block visibility module for this (assuming your question is about D7). Here is a quote from its project page:

The Rules block visibility module allows Rules components to be used to control block visibility. This provides Drupal administrators and developers extreme flexibility in controlling when blocks should be displayed on their websites, in addition to the default visibility options provided by Drupal.

The general idea is that if you can do it with Rules, you can use it to control block visibility, so the possibilities are limitless.

Need to show a block only for users registered more than a month ago?

Perhaps you have a block that must be shown only between 8am-5pm on weekdays?

What about displaying or hiding a block based on current weather conditions?

All of this can be done by using Rules block visibility.

With that, and as per the "if you can do it with Rules, you can use it to control block visibility" above, you've reduced your question to making Rules "check the path of the current page" (so that the block is only shown on your pages with a path that starts with "members/", but not on those pages that have a path ending with "/likes").

For an illustration of how to use this module, refer to my answer to "How to stop a Views block from displaying to admins, such as user/1?". It includes a Rules Component (in Rules export format), which you should replace by this variation of it to make it match your specific question):

{ "rules_block_visibility_show_on_selected_member_pages" : {
    "LABEL" : "Show block on selected member pages",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
      "module" : { "label" : "Module", "type" : "text" },
      "delta" : { "label" : "Delta", "type" : "text" },
      "result" : { "label" : "Result", "type" : "boolean", "parameter" : false }
    "IF" : [
      { "AND" : [
          { "text_matches" : {
              "text" : [ "site:current-page:path" ],
              "match" : "members\/",
              "operation" : "starts"
          { "NOT text_matches" : {
              "text" : [ "site:current-page:path" ],
              "match" : "\/likes",
              "operation" : "ends"
    "DO" : [ { "data_set" : { "data" : [ "result" ], "value" : "1" } } ],
    "PROVIDES VARIABLES" : [ "result" ]

Also, if you'd replace the 2nd Rules Condition in the above Rules Component with something using an appropriate regular expression, you could even further refine it, to check for something like "members/uid/likes", whereas uid corresponds with some user's uid, and so that the block would be shown anyway on pages with a path like "members/with/lots/of/likes".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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