I have written a custom module which generates a PDF when a Webform is submitted and mails it to the admin. I am using the Print module to generate the PDF. The problem is, it seems to use the user's permissions when generating the PDF, and not the admin's. This is generally ok for authenticated users, but for guests, it just fails completely.
I have enabled "Access the PDF version" and "Access own webform submissions" permissions for all users (anonymous and authenticated), but I guess "own" still checks for a user ID and fails for guests.
The Print module uses this code to get the content of the $node from the url
$node = new stdClass(); $node->body = menu_execute_active_handler($path, FALSE);
And here is how I am using the Print module to generate the PDF contents
module_load_include('inc', 'print_pdf', 'print_pdf.pages'); $pdf_url = 'node/' . $nid . '/submission/' . $sid; $file_content = module_invoke('print_pdf', 'generate_path', $pdf_url);
When it's a user with permission (authenticated), this works fine, it generates and mails the PDF successfully. The contents of
$node->body are fully populated.
However, when it's a guest, the contents of
$node->body is just an integer. Is there any way for me to tell it to bypass the permissions when generating the PDF? Or is there a better, secure way around this?