Problem: invite_by_email_send_invitation() receives an invite object that is outdated, meaning that token replacements are not done on it yet.
Proposed solution: load the existing invite object with the entity wrapper to make sure the correct invite object is used.
Comments
Comment #1
klausiPatch attached.
Comment #2
ryan osītis commented#1 didn't seem to work for me. I'm still encountering unreplaced tokens.
It looks like the token replacement is supposed to take place in the function invite_by_email_invite_presave, but the $invite being passed to it doesn't contain the field_invitation_email_body field. Without that, the token replacement can't happen, so it doesn't get modified.
I'm still trying to hash out where the break is happening.
Comment #3
ryan osītis commentedOkay, the invite_by_email_invite_presave function needed to get the email template from the variable table before it could do the token replacement. Give this a try.
Comment #4
Rustan commented#3 seems to have fixed tokens for me, thanks!
Comment #5
skobe commentedGREAT! #3 worked for me too! Thanks!
Comment #6
alibama commentedThanks - #3 fixed it for me too... RTBC?
Comment #7
tjhart87 commentedWorking for me as well ... I believe this is RTBC.
Comment #8
karangarske commentedThanks #3 fixed it for me too.
Comment #9
jweirather commentedThis works for me, with caveats:
I applied the patch after already having applied both:
invite-form-uses-only-one-email-1293118-5.patch
multiple_invite-[1653254#comment-8940639].patch
And received this error:
The reject file was:
Which I was able to manually update at line ~297.
After doing that, tokens began working in the invite email.
Thanks!
Comment #10
Prancz_Adam commentedWhen it will be available in the next dev version?
Comment #11
David_Rothstein commented#3 is incorrect because it gets the template from the variable, but that's not always where it comes from - it can come from the field configuration too.
The bigger question is why the body isn't there in the first place. It looks like this is actually caused by a core bug: #2502263: Drupal 7.36 regression: hidden field textarea #default_value is ignored
I'm not sure if this whole issue is a duplicate of that core bug or just #3 onward, but with the above core patch applied everything seems to be working OK for me.
Comment #12
ckngUnfortunately, submitted patches are wrong solutions.
The main cause is
#2501427: "Use default settings" option doesn't work for mail body and subject; instead the global settings are inconsistently used
and optionally
#2502263: Drupal 7.36 regression: hidden field textarea #default_value is ignored
Marking this as duplicate.
Comment #13
botrisNot sure this should be closed.
- This issue still exists in dev
- @12 marks this as a duplicate of #2501427 & #2502263
- #2501427 is committed in dev
- And after applying #2502263 the problem is remains
- After manually applying the patch from @3 everything works...
Comment #14
ckngCould not reproduce. Try re-saving all the settings after #2501427 & #2502263?
Comment #15
ckngComment #16
botrisResaved all settings, cleared cache, problem remains...
Patch still solves it.
Comment #17
noman_297 commentedI have the same issue invite tokens are not working in email,i opened another issue https://www.drupal.org/node/2562465#comment-10291525 but i find no luck so far,i am still struggling.Any one plz help me out.
Comment #18
pushkar commented#3 fixes the issue of substituting tokens with the right values on email.
Confirmed on Drupal 7.40, running latest beta of invite module.
Comment #19
ckngLet me reiterate.
- Patch #3 is an invalid approach, as that's not the root issue.
- Please use latest dev when you test this.
- Make sure you have applied core patch #2502263.
I'm unable to reproduce this on 2 sites I have after the above are done. So I need new information on how to reproduce this reliably.
- is it new install?
- is it 7.x-2.x upgrade?
- what customization you have done?
- any info that would help to reproduce the issue.
Comment #20
pushkar commentedok, @ckng, Here is what I did
1. Rolled back patch #3, uninstalled invite module,
2. Applied core patch #2502263.
3. Reinstalled the invite 7.x-4.0-beta2
4. The links now work and I can see the Tokens in the email being replaced with the right links.
Of course I am running into the issue of Invite sending thousands of repeat invites but I will re-open that issue.
My environment :
1. Latest Drupal 7.4 ,
2. Have invite, hybridauth, user relationships module. That is it.
3. No other customizations... no custom entities.
Comment #21
ckng@pushkar,
You should try dev instead of beta2.
Comment #22
pushkar commented1. Uninstalled Invite beta
2. Ran cron
3. Installed Latest dev - 7.x-4.0-beta2+17-dev
4. click on send invite and I get a white screen of death :(
5. No emails or logs either
Here are the screenshots (1, 2, 3)
Comment #23
pushkar commentedI tested with a fresh install of latest / greatest Drupal 7 - the latest dev 7.x-4.0-beta2+17-dev does NOT work. I get a white screen of death.
:(
Comment #24
ckng@pushkar, please open new issue. Obviously your install problem is unrelated, but I'm unable to reproduce your problem either. Dev is working just fine https://simplytest.me/project/invite/7.x-4.x
Comment #25
bol3ez commentedI have the beta2 version of invite :
At the begining : tokens indside subject are working, but body tokens are NOT!!
Apply the patch #3 -> clear the cache -> test again -> the same thg not working !
Apply the path in #2502263 (I kept the patch #3 applyed ) -> clear the cache -> test again -> and the magic happen, all the tokens are replaced :)
Thanks for all your effort to figure out the problem.
Comment #26
romansta commented#25 worked for me. Thanks.
Comment #27
MorinLuc0 commentedJust updating @rositis patch to also fetch the subject variable,
This was required in conjunction with 1679172 adding the ability to translate the invite variable text.
Comment #28
SpartyDan commentedClosing this issue - cannot reproduce.
Please read #19 by ckng.
Also see patch #6 on Issue #2626076
I also cannot reproduce this issue on my two clean installs.
If you still encounter this issue while using the latest dev release please open a new issue and include the steps that you took to reproduce the issue.
Comment #29
nithinkolekar commentedwith the latest dev release 7.x-4.0-beta4+5-dev (2016-Dec-06) and Drupal core 7.51 which has commited #2502263: Drupal 7.36 regression: hidden field textarea #default_value is ignored patch , Email token replacements is still not happening.
update : forgot to mention whole body value is empty both in invite node and also in received mail.
Comment #30
SpartyDan commented@nithinkolekar
As one of the maintainers of this module, I very much want to fix this issue. However, we have clearly stated that we can't reproduce this issue.
Please help us. If you can reproduce this issue, please provide us with a detailed description of your configuration including screenshots of the /admin/config/people/invite and /admin/config/people/invite/by_mail pages.
Please also provide the steps that can be repeated on a clean Drupal 7 install to reproduce the issue.
It is very difficult to fix a problem that we can't reproduce. If you can help us by showing us how to reproduce the issue on a clean Drupal 7 install. We will fix the issue, post our code here, and commit the fix.
Thank you, in advance, for your help in fixing this issue.
Comment #31
nithinkolekar commentedjust tested with fresh install and while checking with possible different configuration , found out that changing field_invitation_email_body to user "Filtered text (user selects text format)" did the trick to replace the token in body field but empty subject.
No other additional steps are required other than enabling invite and invite by mail module.
module versions
Drupal core 7.52
Invite 7.x-4.0-beta4+5-dev (2016-Dec-06)
Entity API 7.x-1.8+1-dev (2016-Sep-28)
Token 7.x-1.6+8-dev (2016-Apr-08)
also attaching the screenshots of different config
Comment #32
SpartyDan commented@nithinkolekar
Thank you. I will look into this and should have it fixed this week.
Comment #33
SpartyDan commentedComment #35
cassio commentedwhat versions should we upgrade to in order to take advantage of the fix? dev? invite, and token?
I saw two different body field variations when testing input formats and saving:
1. blank
2. tokens being echoed but not replaced
Comment #36
SpartyDan commented@cassio
The current version of invite is 7.x-4.0-beta5.
If the invite module is not performing correctly please provide detailed information regarding what the error is and what steps can be taken to reproduce the error.
Comment #37
nithinkolekar commentedI tested with beta5 and it is working fine but issue was closed by @SpartyDan before marking it as RTBC.
changing status to RTBC so @cassio or others can test it.
Comment #38
SpartyDan commentedI completed extensive testing of the patch and committed it so I marked the issue as Fixed.
If there is a new problem with this module, please open a new issue.
Comment #40
samirsatardekar commentedComment #41
samirsatardekar commentedHI,
I am still facing the same issue. Currently i have tried to patch it by doing following things(might not be correct)
invite_by_email.module line 169
//check if the body variable is not set then set default
if(!isset($invite->field_invitation_email_body[LANGUAGE_NONE][0]['value']))
$invite->field_invitation_email_body[LANGUAGE_NONE][0]['value'] = variable_get('invite_default_mail_body', '');