What data I will get in global $user; used in hook_node_update when drupal 7 cron executes -
i have implemented hook_node_update in module. can access loggedin user data defining global user object global $user;. need know loggedin user , content creator process instructions.
the question if node scheduled unpublished , when drupal runs cron in global $user;? same user made change in node or else? there way access data of user last updated node?
update:
i think failed explain need. consider scenario.
there 2 users, , b. created content (node) example. when b changes in example need send email notification a. when example content scheduled archived user b, cron task saved , executed cron. when cron runs, @ point how can know scheduled b?
the global $user object always:
an object representing user visiting site.
that can either authenticated user, or anonymous user (uid=0) if applicable.
so if user creates/edits node through ui, , implementhook_node_update(), $user object of user responsible creating content, expect.
drupal runs cron anonymous user, doesn't create session based on unrelated contextual data user id attached arbitrary node - such workflow wouldn't make sense.
to user object node object, can use user_load():
$account = user_load($node->uid);
Comments
Post a Comment