hook_count_user_subscriptions

Definition

hook_count_user_subscriptions($count, $uid)
subscriptions_og/docs/hooks.php, line 224

Description

Declare a subscription plugin count handler.

When subscriptions module generates page user overview, it calls every plug-in available to provide the amount of subscriptions a user have. Note that this implementation uses _module_types() in order of construct resulting array.

See also

subscriptions_page_user_overview()

Parameters

$count It is the array where we can store our count. WARNING! must not be overriten, but only inserted with your plugin array key.

$uid User account ID to filter subscriptions used to count.

Return value

Array with count of current plugin subscriptions.

Related topics

Namesort iconDescription
HooksAllow modules to interact with the Drupal core.

Code

<?php
function hook_count_user_subscriptions($count, $uid) {
  $type   = _module_types();
  $fields = $type['group']['fields'];
  $_query = "
SELECT count(*)
FROM {subscriptions}
WHERE
  module = 'node' AND
  field = 'group_nid' AND
  recipient_uid = %d
  ";
  $count[$fields[0]][$fields[1]] = db_result(db_query($_query, $uid));
  return $count;
}
?>