How can this be achieved?


tea.time’s picture

I'm in a similar situation...

If you're using the flag_create_link() function, you'll notice that if the particular flag's settings do not allow the user to use the flag, then no markup at all is returned.

To get around this, I think you'd have to give anon users the permission to use the flag, and then create your own theme's implementation of flag.tpl.php which checks for the anon user and simply sets the flag link to go to /user/login.

On second thought, for the sake of (a) avoiding using a false permission setting as a workaround, and (b) moving the logic to run earlier, I realized it would be better to check whether the user is logged in and then either print a placeholder link to log in or run flag_create_link(). E.g.:

global $user;
$user->uid > 0) {
flag_create_link('favorites', $node->nid);
else print
l("Log in to favorite", "user/login");
joachim’s picture

Status:Active» Fixed

Closing support requests older than a year. Feel free to reopen if this is still relevant.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.