I'm creating my own small module where I would like to get some data after submitting other forms. To be more specify I would like to retrieve some variables after submitting form.

For example: form is created by privatemsg module and I want to get $sent variable value.

My idea was to create, in my module form_alter hook and use submit. But I couldn't find how to use and retrieve variables value.

Below the code from privatemsg module

function privatemsg_new_form_submit($form_id, $form_values) {
  global $user;
  static $seen = array();
  if ($form_values['op'] != t('Send private message')) {
    return FALSE;
  }

  $recipients = explode(',', $form_values['recipient']);
  $sent = FALSE;
  foreach ($recipients as $recipient) {
    $recipient = trim($recipient);
    if (isset($seen[$recipient])) {
      continue;
    }
    $seen[$recipient] = TRUE;
    $recipient = user_load(array('name' => $recipient));
    $message_id = _privatemsg_send($user, $recipient, $form_values['subject'], $form_values['privatemsgbody'], $form_values['format'], $form_values['thread']);
    if ($message_id) {
      // Load the message for consistency.
      $message = privatemsg_load($message_id);
      // Tell the other modules a new private message has been sent.
      privatemsg_invoke_privatemsg($message, 'sent');
      $sent = TRUE;
      
      
    }
  }

Can someone advice me the way to retrieve variable values on submit?

Comments

alim418’s picture

<?php
function yourmodule_privatemsg(&$message, $op) {
  switch($op) {
    case 'sent':
     //your module code to do extra implementations (e.g) drupal_set_message('Hello there from your module name');
     break;
  }
}
?>
CristinaM’s picture

THX a lot alx, this is exact solution for my problem.