Could you implement some hooks in the module, so it allows other modules to add stuff to the signature?

Comments

hlopes’s picture

I have no clue how this module works, but need to append something to the signature with another module without touching the db.

Normally i would do something like

$account->signature .= 'something'; on the user_hook, op load.

I've tried to change $account->signature_forum: no go.
I've tried to override the theme function: no go, as i need the user id to compute the thing i want to append.

I've altered the modules weights and everything, but to no avail.

Any suggestions?

Niklas Fiekas’s picture

Category: feature » support

It's implemented like this:



/**
 * Implementation of hook_nodeapi().
 */
function signature_forum_nodeapi(&$node, $op, $teaser, $page) {
  if (!$teaser && $op == 'view') {
    $settings = variable_get('signature_forum_settings', signature_forum_defaults());
    if ($settings['signature_forum_auto_insert']) {
      $node->content['body']['#value'] .= signature_forum_get_signature($node); // <---
    }
  }
  // Save signature setting for this node.
  elseif ($op == 'insert' || $op == 'update') {
    $delta = $node->nid;
    $status = $node->signature_forum;
    signature_forum_save_comment_status($delta, 'node', $status);
  }
}

/**
 * Implementation of hook_comment().
 */
function signature_forum_comment(&$comment, $op) {
  if ($op == 'view') {
    $settings = variable_get('signature_forum_settings', signature_forum_defaults());
    if ($settings['signature_forum_auto_insert']) {
      $comment->comment .= signature_forum_get_signature($comment); // <---
    }
  }
  elseif ($op == 'insert' || $op == 'update') {
    $delta = $comment['cid'];
    $status = $comment['signature_forum'];
    signature_forum_save_comment_status($delta, 'comment', $status);
  }
}

That means you could append your values in your own implementations of those hooks, if they run after signature_forum (thus the weights you already mentioned). See <-- for where to append.

If signature_forum_auto_insert isn't enabled, you could still do it on the theme layer.

hlopes’s picture

  $signature = sprintf($settings['signature_forum_template'], trim($signature));

  $signature = implode(module_invoke_all('signature_forums_alter', $a1, $signature));  //  <--------

  return theme('signature_forum', $signature);

Any reason why i shouldn't do something like this?