Flag content programmatically

Public

Programmatically flag any content: node, taxonomy, user. Put this into your code:

</> CopyGet raw version
php
  1. // Get flag by its name
  2. $flag = flag_get_flag('bookmark');
  3.  
  4. // Pass content id, user object on which behalf you want to flag and ignore permissions check if needed
  5. $flag->flag('flag', $content_id, user_load($uid), TRUE);