Flags: get Action after a user flagged a specific number of nodes? I would like the users of my site to choose a specific number of nodes. After this they should see, to which taxonomy term these nodes belong to.

I have already found the flag module as well as flag limiter module. I have put the limit to 12 (This is the amount of nodes the user should be able to choose).

Now I would like that the user is redirected to a new page (where he can see the belongig taxonomy terms to his flagged nodes - this I can manage to create with views), after he flagged the 12th node.

Could anyone help me, how to achieve this?

Thanks,
Tabea
You can able to detect limit has reached using hook_flag_flag hook exposed by flag module..

Flag Limiter module uses the same logic to detect the limit as you can see the below code

function flag_limiter_flag_flag($flag, $entity_id, $account, $flagging) {
  // Get the flag limits.
  $flag_limit = variable_get('flag_limiter_' . $flag-&gt;name . '_value', 0);
  $peritem_limit = variable_get('flag_limiter_' . $flag-&gt;name . '_peritem_value', 0);

  if ($flag_limit) {
    $user_flags = flag_limiter_get_user_flags($account-&gt;uid, $flag-&gt;fid);
    if (count($user_flags) &gt; $flag_limit) {
      $unflag = flag('unflag', $flag-&gt;name, $entity_id, $account, TRUE);
      if ($unflag) {
        drupal_set_message(t("You've already signed up @num times", array('@num' =&gt; $flag_limit)), 'error');
      } else {
        drupal_set_message(t('Fail limiter operation'), 'status', FALSE);
      }
    }
  }

  if ($peritem_limit) {
    $flagging_data = flag_get_counts($flag-&gt;entity_type, $entity_id, TRUE);
    if ($flagging_data[$flagging-&gt;flag_name] &gt; $peritem_limit) {
      $unflag_item = flag('unflag', $flag-&gt;name, $entity_id, $account, TRUE);
      if ($unflag_item) {
        drupal_set_message(t("The event already signed up @num times", array('@num' =&gt; $peritem_limit)), 'error');
      } else {
        drupal_set_message(t('Fail limiter operation'), 'status', FALSE);
      }
    }
  }
}


You can implement same hook in your custom module to redirect user to the page you want.. You can use drupal_goto function to redirect user..

function YOURMODULENAME_flag_flag($flag, $entity_id, $account, $flagging) {
  if ($flag_limit) {
    $user_flags = flag_limiter_get_user_flags($account-&gt;uid, $flag-&gt;fid);
    if (count($user_flags) &gt;= $flag_limit) {
      drupal_goto('path');
    }
  }
}


writing custom module instructions ..


Create a folder called "custom" inside sites/all/modules
Create a folder called "myflaglimit" inside sites/all/modules/custom/
Create a file called "myflaglimit.info" inside "myflaglimit" folder create above.
Put in below code and save file


Below code goes into myflaglimit.info file..

name = My Flag Limit
description = Provides a redirect on reaching limit.
core = 7.x
package = Custom
dependencies[] = flag_limiter


Your logic goes into .module file


Create a file called myflaglimit.module file inside myflaglimit folder you have create with below code
You extend drupal function using hooks which are nothing but functions which starts with modulename_hook


use below code inside module file

&lt;?php
function myflaglimit_flag_flag($flag, $entity_id, $account, $flagging) {
  if ($flag_limit) {
    $user_flags = flag_limiter_get_user_flags($account-&gt;uid, $flag-&gt;fid);
    if (count($user_flags) &gt;= $flag_limit) {
      drupal_goto('path');
    }
  }
}