You are here

function og_notifications_user_subscribe in Organic groups 5.8

Same name and namespace in other branches
  1. 5 og_notifications/og_notifications.module \og_notifications_user_subscribe()
  2. 5.3 og_notifications/og_notifications.module \og_notifications_user_subscribe()
  3. 5.7 og_notifications/og_notifications.module \og_notifications_user_subscribe()
  4. 6.2 modules/og_notifications/og_notifications.module \og_notifications_user_subscribe()
  5. 6 modules/og_notifications/og_notifications.module \og_notifications_user_subscribe()

Subscribe a user to a group.

Parameters

Object $account: The user account object.

Integer $gid: The node ID of the group being subscribed to.

2 calls to og_notifications_user_subscribe()
og_notifications_og_upgrade in og_notifications/og_notifications.install
Notifications upgrade: Based on the upgrade flag, move existing subscriptions to the notifications module.
og_notifications_user_autosubscribe in og_notifications/og_notifications.module
Handle autosubscriptions for users when they join a group.

File

og_notifications/og_notifications.module, line 529
Provide notifications and messaging support for organic groups.

Code

function og_notifications_user_subscribe($account, $gid) {
  $subscription = _notifications_subscription_defaults($account);
  $subscription['uid'] = $account->uid;
  $subscription['type'] = 'group';
  $subscription['event_type'] = 'node';
  $subscription['fields'] = array(
    'group' => $gid,
  );
  notifications_save_subscription($subscription);
}