I have some old D6 code which I am converting to D7.
The code does something like this:

  if ( !notifications_get_subscriptions(array('type' => $type, 'uid' => $account->uid), array($field => $value))) {
    $subscription = array(
      'uid' => $account->uid,
      'type' => $type,
      'fields' => array($field => $value),
    );
    notifications_save_subscription($subscription);

But in D7, it now in produces an error:

Call to a member function set_subscription() on a non-object in ...\sites\all\modules\notifications\notifications.subscription.inc on line 1152

Please can anyone confirm if the hooks have changed? I could not see any changes. Thanks

Comments

zeezhao created an issue. See original summary.

zeezhao’s picture

Just found some documentation for D7 api here: https://www.drupal.org/node/1711802

Will try this out.

edit:
Now gives:

"Call to undefined method Notifications_Subscription::set_node()"

even though including the required classes and doing as suggested:

  $subscription = new Notifications_Content_Subscription();
  $substype = notifications_subscription_type_load($node->type);
  $subscription = $substype->instance()->set_user($account->uid)->set_node($node);
  $subscription->save();
zeezhao’s picture

Title: Call to a member function set_subscription() on a non-object in ... notifications.subscription.inc on line 1152 » Call to undefined method Notifications_Subscription::set_node