Hide a block when viewing own profile page - Show when viewing other people's profile? I have a "Feedback" form implemented on a block. This block displays only when viewing the user profile page.

To stop people rating themselves, I would like to hide this block when the logged in user is viewing their own profile page. 

This block should only show when viewing other people's profile pages.

I am using Drupal 8.

How can I do this please?

Here is the code I am currently using: 

The issue is a person should not see the block when viewing their own profile page. They should see the block only when viewing another person's profile.

/**
 * Hide feedback form to prevent self voting.
 */
 use \Drupal\block\Entity\Block; 
 use \Drupal\Core\Session\AccountInterface;

function zup_hide_feedback_form_block_access($block, $account) {

    $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()-&gt;id());
    $uid= $user-&gt;get('uid')-&gt;value;

    if ($operation == 'view' &amp;&amp; $block-&gt;getPluginId() == 'block-webform-3') {
        if($account-&gt;id() != $uid){
            return \Drupal\Core\Access\AccessResult::forbiddenIf($block-&gt;getRegion())
            -&gt;addCacheableDependency($block);
        }
    }
      // No opinion.
      return \Drupal\Core\Access\AccessResult::neutral();
}
You can use hook_block_access()

/**
 * Implements hook_block_access().
 */
 function mymodule_block_access(\Drupal\block\Entity\Block $block, $operation, \Drupal\Core\Session\AccountInterface $account) {
  if($operation == 'view' &amp;&amp; $block-&gt;getPluginId() == 'block_id') {
    $uid_from_url = Drupal::requestStack()-&gt;getCurrentRequest()-&gt;get('user')-&gt;id();
    if($account-&gt;id() == $uid_from_url) {
      return \Drupal\Core\Access\AccessResult::forbiddenIf($block-&gt;getRegion())
        -&gt;addCacheableDependency($block);
    }
  }
  // No opinion.
  return \Drupal\Core\Access\AccessResult::neutral();
}


See more document function hook_block_access