I need to hide flag link if the logged in user and the author are same. Please find below codes.

function MODULE-NAME_views_pre_view(&$view, &$display_id, &$args)
    global $user;
    if ($view->name == 'VIEW-NAME' && $display_id == 'DISPLAY-ID') {
        $node = node_load(arg(1));
        if($node->uid == $user->uid){
            //echo 'hide flag';
            //echo 'show flag'; 
  • 1
    Are you using Flag module? can you please add details. Commented Sep 17, 2014 at 10:10
  • 1
    Yes I am using flag module and displaying flag links using view. I need to show link only to other users other than author.
    – Aswini K
    Commented Sep 17, 2014 at 10:19
  • @akm your last comment should be an edit. Also, if you already tried something, examined some configuration forms etc - please share.
    – Mołot
    Commented Sep 17, 2014 at 10:27
  • @akm I guess what you are trying to achieve can be done through the permission of the flags. However, As stated by the Molot please share your finding. Commented Sep 17, 2014 at 11:00

1 Answer 1


If it is a flag on nodes, you just need to set "Users may only flag content of others" in the Flag access by content authorship paragraph of the FLAG ACCESS options.

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.