I'm using the Token Authentication and Privatemsg modules together. When a user receives an e-mail notification that they he/she has received a private message, I have placed a link (using a token provided by the Tokenauth module in a query string) that allows the user to log in and see the message.
At the bottom of the page is the message reply form. I would like the user to be able to reply via this form as well (without logging in, via token authentication). However, when I tested this, I received the following error:
The form has become outdated. Copy any unsaved work in the form below and then reload this page.
A Google search revealed this helpful comment on drupal.org:
So it seems you would have to either
unset($form['#token']) or $form['#token'] = NULL
Privatemsg has two message creation forms, the new message form and the reply to message form.
To fix the new message form, I added
hook_form_privatemsg_new_alter() (new messages) and
hook_form_privatemsg_form_reply_alter() (replies). I tested this and new private messages as well as replies can now be sent.
I then disabled caching for the privatemsg module so that the messages would always be refreshed.
However, I have a rule that is set to Show a message on the site ("Your message was sent to User X!") whenever a private message or reply is sent; this rule is not triggered when a private message is sent if the user is authenticated via Tokenauth even though the private message is saved to the database properly and displayed upon page refresh.
How can I make sure rules are still triggered when authenticated via Tokenauth?