0

It is possible with the following code to check if a content has been flagged by the current user with a certain flag:

$flag = flag_get_flag('flag_name');
if ($flag && $flag->is_flagged($node->nid, $GLOBALS['user']->uid)) {
  print "This node is flagged";
}

But, how to check if the user has flagged content with any flag ?

0

The flag module has a utility function flag_get_flags() that retrieves multiple flags, with an option to filter on the entity type of the flag:

// Same logic, looped over multiple node flags:
$flags = flag_get_flags('node')
foreach ($flags as $flag_name => $flag) {
  if ($flag && $flag->is_flagged($node->nid, $GLOBALS['user']->uid)) {
    print "This node is flagged";
  }
}

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.