[development] Send Contents of new node by email

Ernst Plüss ernst.pluess at gmail.com
Wed Jan 27 15:20:27 UTC 2010


Hi Drupalfriends

After the user hits "Send" for a new cck node, I'd like to send the contents
of this node by email. In order to do so I installed the print module.

Then I call the appropriate function of the print module in hook_nodeapi.
This works fine as long as I am the admin user.

The anonymous user gets the access denied page. After some debugging it
turned out, that at this point the node_access table is not yet written,
which makes the access check of the print module thinking the anonymous user
does not have the right to view this node.

Any ideas to solve this problem?
Best Regards
Ernst



My code in hook_nodeapi:

      case 'insert':
        // Mail distribution
        // To: Gad Intake
        module_load_include('inc', 'print_mail', 'print_mail');
        $form = array();
        $form_state = array(
          'values' => array(
            'fld_from_name' => 'Gad Formulare',
            'fld_from_addr' => 'form at gadform.ch',
            'chk_teaser' => 0,
            'path' => 'node/'.$node->nid,
            'fld_subject' => t('New Registration'),
            'txt_to_addrs' => variable_get('zuweisung_intake_mail_adr', '
intakeuser007 at gmail.com'),
          ),
        );
        print_mail_form_submit($form, $form_state);
        // To: The institution filling in the form
        $form_state['values']['txt_to_addrs'] =
$node->field_zuw_email['0']['email'];
        print_mail_form_submit($form, $form_state);
        break;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100127/ba675442/attachment.html 


More information about the development mailing list