Skip Navigation

[Résolu] Which CRED API hooks execute last?

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
Client is sending a notification and needs to update the post after the notification has been sent, and wants to know which are the last hooks that can be used.

Solution:
In reverse order:

cred_success_redirect
cred_mail_header
cred_notification_recipients
cred_submit_complete
cred_save_data

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/

This support ticket is created Il y a 6 années et 4 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Ce sujet contient 20 réponses, a 2 voix.

Dernière mise à jour par julieP Il y a 6 années et 4 mois.

Assisté par: Nigel.

Auteur
Publications
#1070223

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Screen Shot 2018-08-01 at 13.36.11.png

I'm sending the notification to the admin and to the email address from the field in the form, not the "post author", and the email is being sent to both.

I would first use a plugin like WP Mail Logging to check what's being sent (rather than what it being received). On my test site both email addresses are added to the To: field.

#1071370

Hi Nigel

My mail debug log only shows the one email being sent but I can see (now) why it's working for you and not me; I always have one notification per recipient generally because the message I send to the user is different to the message I send to myself. For this particular scenario, it's not actually not overly important.

I really appreciate your help with this, thank you!

Before I close this ticket, can I ask (as it's related); is it even possible to display different content to the two recipients in the email body? I'm not quite sure how wpv-conditional would work here (I did try using it by targeting my user ID but only the user's message displayed).

#1071392

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

You send two notifications, one to yourself (the admin) and one to the person submitting the form.

And the problem is that the first notification deletes the email address before the second one gets to use it, is that right?

Well, the arguments for cred_mail_header include the notification name & number, so you can target just one of the notifications.

If you do a few tests and find that the admin notification consistently happens before the client notification you can specify in your code the notification name of the client notification and only then delete the email address.

#1071465

Ah OK; I was looking to achieve it in the wrong place! Notification name I can find but where do I find the number (that would be the better one to target in case I change the name)? I've looked in the serialized data but nothing's obvious.

#1072490

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Uhm, I'm not sure!

I suggest you simply output the notification number argument to your debug.log and you will see.

Note that these hooks used to only have the notification number, but that could change when migrating sites and so the notifications would no longer work, hence the notification slug was added to avoid this potential issue.

#1072492

Ha Ha - that made me laugh! I'll give it go. I can confirm in the meantime that targeting the notification name in the code works so I'm well happy - thank you!!