Flag the node after login I am using flag module to bookmark the content. Authenticated user can normally flag the content. For anonymous user when they click on flag link it should go to login page. After successful login it should flag the node automatically.
I have the code for flagging the content, but I could find how to flag after login.
$flag = flag_get_flag('wishlist');
$flag-&gt;flag('flag', $nid, user_load($uid), TRUE);
You can try using hook_node_view for doing this.
What it does is:


  Act on a node that is being assembled before rendering.


Here is an idea to try out:

/**
 * Implements hook_node_view
 */
function yourmodule_node_view ($node, $view_mode, $langcode) {

  // use a one-timer boolean for this action
  if(user_is_logged_in() &amp;&amp; !isset($_SESSION['autoflagging_once']))
  {
    $_SESSION['autoflagging_once'] = true; 
    $flag = flag_get_flag('wishlist');
    $flag-&gt;flag('flag', $node-&gt;nid, user_load($uid), TRUE);
  }

}


Good luck!