I can't (as the administrator) remove other users' flags (or clear them) using Views.

How can I remove flags from other users with Views?

I don't want to reset all the flags for a node, but I want to remove a user's flag on a particular content.

Comments

quicksketch’s picture

This is not generally possible (for a variety of reasons). See #593300: Changing a different user's node flags.

Alcaparra’s picture

Ok, thanks.

I found the module "Views Custom Field". This module can add a field with php code. Can you help with code?

Views Custom Field: http://drupal.org/project/views_customfield

quicksketch’s picture

I can refer you to the Flag API: http://drupal.org/node/305086. You probably just want to call the flag() function: http://api.lullabot.com/flag

Alcaparra’s picture

Thank you quicksketch. This is the comment in "Views Custom Field" Issues. Maybe you can help:

http://drupal.org/node/890036

Alcaparra’s picture

I tried:

<?php
echo '<a href="' . flag('unflag', 'nid', $account = 'users_flag_content_uid', $skip_permission_check = TRUE) . '">Unflag</a>';
?>

but nothing happens. Do you know what is the problem?

mooffie’s picture

Alcaparra, the main problem with your code is that it runs automatically when you view the page. You want the code to run only after you explicitly click some link.

I asked for help at the Rules project, perhaps they can help us.

(Nate, #871064: Making flaggings fieldable will probably introduce this feature, but I prefer not to talk about this yet because unless you see the code, which is quite simple, you might get the impression I plan some code bloat.)

Alcaparra’s picture

I try to make a module for this problem. Can you help me? http://drupal.org/node/890910

mooffie’s picture

It's easier to write the module than to teach/fix another. Perhaps I'll try to do it later this day/week, but I'm engaged in other things so I don't want to promise.

mooffie’s picture

Are you still looking or this functionality?

I wrote a little module to do this. But I now see that there are gazillions of patches here intending to do similar things (I'm most of the day off-line, so couldn't check).

mooffie’s picture

(You emailed me that you're still interested.)

You can download the module here:

http://github.com/mooffie/flag_clear/archives/master

Important: the module requires the most recent version of Flag, known as 'dev', which you can download here:

http://drupal.org/node/576390

(You will see strange errors if you don't use the 'dev'.)

========

After installing this module you'll find a new field, "Flags: Remove link". (There's also a Reset link.) You'll see it after you bring in the "Flags: Node flag" (or "Flags: Comment flag", or whatever) relationship, as usual.

If you encounter problems, let us see your exported view.

========

(If any programmer here is interested in maintaining this module, let me know.)

mooffie’s picture

Important: the module requires the most recent version of Flag, known as 'dev', which you can download here:
http://drupal.org/node/576390

In case you're a Drupal novice, here are instructions:

After extracting the 'dev' version you'll have to click the button on Drupal's Modules page. This clears Drupal's cache. Then, if you can edit your flags' settings, and flag and unflag content, it means all is fine.

Alcaparra’s picture

I'm using Flag 6.x-2.0-beta3 and your module seems to work well. What is the problem you've had ("You will see strange errors if you don't use the 'dev'."?

One suggestion, it would be nice if we could choose the type of link (JavaScript toggle, Normal link or Confirmation form) or to use flag link settings.

Thank you very very much for sharing your module ;)

mooffie’s picture

I'm using Flag 6.x-2.0-beta3 and your module seems to work well. What is the problem you've had ("You will see strange errors if you don't use the 'dev'."?

This moule provides two links:
1. Removing one flagging ("Remove link").
2. Removing all flaggings ("Reset link").

The first link, which you're using, indeed doesn't necessitate the 'dev' version.

But the second one, the reset link, does require the 'dev' version because is has the following line of code:

$items['flag/reset/%flag/%'] = array(

This '%flag' thing is only in 'dev'.

One suggestion, it would be nice if we could choose the type of link (JavaScript toggle, Normal link or Confirmation form)

The reason the links don't use JavaScript is because a refresh of the whole view is necessary (because the entire table row should go), and our current JavaScript doesn't (and shouldn't) handle this. But I'm aware of this glitch.

Alcaparra’s picture

thanks for responding so quickly. your module is great.

mooffie’s picture

Status: Active » Closed (fixed)

The module now has a homepage at Flag Clear. I'm closing this issue.