Could you suport hook_notify()?

Created on 8 March 2011, almost 14 years ago
Updated 31 March 2024, 10 months ago

Hello.

I think very usefull hook. hook_notify();
I made this. it very few code.

/**
 * Displays a notification message when an invited user has registered.
 *
 * @param $uid
 *   The user id to check accepted invitations for.
 */
function invite_notify($uid) {
  $result = db_query('SELECT invitee FROM {invite_notifications} WHERE uid = %d', $uid);
  while ($row = db_fetch_object($result)) {
    $account = user_load(array('uid' => $row->invitee, 'status' => 1));
    if ($account) {
      drupal_set_message(t('!user (@email) has joined @site-name!', array('!user' => theme('username', $account), '@email' => $account->mail, '@site-name' => variable_get('site_name', t('Drupal')))));
      db_query("DELETE FROM {invite_notifications} WHERE uid = %d AND invitee = %d", $uid, $row->invitee);
     
      //I add this
      $args = array('invitee' => $account, 'inviter' => $uid);
      module_invoke_all('invite', 'notify', $args);
    }
  }
}

/**
 * Implementation of hook_invite().
 */
function hook_invite($op, $arg) {
  switch($op) {
    case 'notify':
      //example
      $flag = flag_get_flag('flag_name');
      $flag->flag('flag', $arg['inviter'], $arg['invitee'], TRUE);
      $flag->flag('flag', $arg['invitee']->uid);
    break;
  }
}

💬 Support request
Status

Closed: outdated

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024