Skip Navigation

[Escalated to 2nd Tier] Custom code + CRED Post Edit Form = Notifications sent when form is updated

This support ticket is created 5 years, 11 months ago. 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.

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+01:00)

Tagged: 

This topic contains 10 replies, has 2 voices.

Last updated by Sean 5 years, 10 months ago.

Assisted by: Nigel.

Author
Posts
#1263383

I am trying to: Update the WordPress user display name via a custom field value in a Toolset post edit form using cred_submit_complete and wp_update_user() in a custom code snippet

Link to a page where the issue can be seen:

I expected to see: The updated user's display name in addition to the other updated custom fields submitted by the form.

Instead, I got: The user display name and all custom fields are updated as expected however, a form notification from a user edit form is being sent every time the post edit form is updated. If I remove wp_update_user() from the custom code snippet, the errant email notification from the user form is no longer sent when the post edit form is updated.

#1263689

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Sean

What are the settings for the notification on the user form that are being triggered by wp_update_user?

#1264187

Hello, Nigel!

The settings for the notification on the user form is "when custom fields are modified and only if the field value has changed". It's set to sent a notification to the user only if one particular custom field is changed and equals "approved".

#1264289

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

And when you use wp_update_user to update the user's display name you are not changing any other fields, in particular the approved custom field?

#1264455

Correct, I am not changing the custom field with value "approved" but there are other custom user fields that may get updated based on the information submitted by the post edit form.

#1265199

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Sean

We have two known issues with Form notifications, and I've been doing some testing to see whether they apply to User Forms (they are reported for Post Forms).

https://toolset.com/errata/issues-with-form-notifications-for-posts-created-or-edited-in-the-backend/
https://toolset.com/errata/forms-notifications-always-sent-when-its-condition-depends-on-a-radio-field/

With the first issue, notifications are being sent whenever *ANY* user meta is changed (so long as the condition is met) rather than only when the field being tested has changed value.

Is your custom field with value "approved" a radio field?

#1265569

My custom field with value "approved" is a select field.

#1266347

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Thanks Sean.

Sorry, one last thing. From your various replies I can't tell whether the field with value "approved" is actually set to approved, or whether it is set to something else and the notifications are being sent even though the field value doesn't match the requirement in the notification.

So you are either covered by that first erratum already (it just needs updating to say that user forms are affected as well as post forms), or I need to test that second erratum to see if the problem reported for radio fields affects select fields, too.

#1267133

Gotcha!

Yes, the custom field value is set to "approved" when the user form notifications are sent - whether the field value has been changed or not. The field value does indeed match the notification requirement for the form.

#1267485

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

OK thanks, that means this is covered by that first existing issue.

I'm escalating this thread and attaching it to the same internal ticket.

We'll update the erratum to make it clear user forms are affected, too, and I've asked to give some priority to fixing this as the issue has already been open for a while.

I'll keep you posted.

#1268193

Thank you, Nigel!