Skip Navigation

[Resuelto] Notification when custom image field is changed

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:

The issue here is that the user wanted to send a notification using CRED when their user edits an image field on the form.

Solution:

The solution can be seen below.
https://toolset.com/forums/topic/notification-when-custom-image-field-is-changed/#post-1244707

This support ticket is created hace 5 años, 6 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Este tema contiene 30 respuestas, tiene 2 mensajes.

Última actualización por FelipeP5703 hace 5 años, 5 meses.

Asistido por: Shane.

Autor
Mensajes
#1241826
notification_email_fotos.jpg

Tell us what you are trying to do?
I setup a notification email notice to alert the admin when the custom image field is changed. I looked into this article here but it does not say anything about custom field being modified: https://toolset.com/documentation/user-guides/automated-email-notifications-with-cred/#when-to-use-field-conditions

Therefore, when selecting the custom image field for single image or for multiple images, I'm not sure what condition to setup.

As you can see on the screenshot, I placed both "Foto Perfil" and "Fotos para Anuncio" as <> to empty (because I was not sure what to put in that field).

It works fine if the User changes the photos (either one), but it also sends a notification if the user does not change the photos but instead change something else.

So what I want is to ONLY receive a notification if the user changes one of the photos. If they change anything else, I do not want to receive an email.

How do I set that up?

#1241925

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Felipe,

Thank you for contacting our support forum.

Based on the logic of this, the email notification should only be sent only if the image field is modified.

I'm assuming this is an edit form correct? So even if the image field hasn't change the notification is still sent. I think the issue is with the available logic for the fields.

I took a look at the available logic and there isn't an option that can be selected for this. I think this should come under the option for improvement.

Please let me know what you think of this so that we can move forward with this.

Thanks,
Shane

#1241929

Yes, this is an edit form.

To me, it's only logical if there is a setting for notifying a user or admin about a specific custom field change and it's not working, then yea it should be fixed.

There are a lot of things that development team created without thinking it through before releasing. Sounds like Apple... create a product as is... release to the masses... and try to improve on the next one. Kind of crappy way of doing things from my point of view.

Anyways... yea please improve this asap. Thanks

While at it, maybe in the body of the notification have a placeholder or something that identify what changed. What I mean is, there is also no way to notify the user or admin of what has changed in the form, only a notification that it had changed.

#1241932

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Felipe,

While I can report the notifications for improvement. I would suggest creating a feature request for the body notifications.

This way you can add what it was before and what it is now, kind of like a changes table.

You can suggest it here.
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

Please try to be as detailed as possible for this one.
Thanks,
Shane

#1241941

I've done so... let's see what happens. Is there a work around? I only want to be notified if the user changes the images custom fields

#1243057

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Felipe,

Sorry for the delayed response.

I was trying to figure a workaround to get this to work for you but I wasn't able to unfortunately.

Maybe what you can try doing is to add a checkbox that is hidden and use js to check to see if the field value for the image has changed.

If it has changed then the js will fire and then select the checkbox. However we must load the checkbox unchecked initially. Then you can set your notification based on whether the checkbox is checked or not.

I was taking a look a this stack overflow here.
https://stackoverflow.com/questions/959670/generic-way-to-detect-if-html-form-is-edited

Please let me know what you think of this solution and if you need some assistance implementing.

Thanks,
Shane

#1243099

So you are saying to create a custom field (checkbox) for one the featured image and another for the other images (multiple images) and hide them with CSS. Then use JS to check the checkbox if there is a change on them.

I can create the checkboxes, do I create two? One for the feature image and another for the other images?
I know how to hide them.
I just don't know what the JS would be, can you help me out please?

#1243228

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Felipe,

Yes that is correct.

If you could provide me with access to the site and the edit form on the frontend I can write up some JS for you to get this to work.

Thanks,
Shane

#1243828

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Felipe,

I've found the form on the backend but could you send me a link to an edit page where the form is on so that I can test the workaround ?

Thanks,
Shane

#1243835

You have to login as an user in order to see the edit form... I sent you the login on the private message... use incognito... once you login, click on Tamy's "Editar" button and it will take you to the form

#1244066

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Felipe,

Pardon my many questions but i'm not seeing an edit button on the profile on the frontend enlace oculto

The only thing I see is the edit link that takes me to the backend.

Thanks,
Shane

#1244101

Follow the instructions here - enlace oculto

#1244707

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Felipe,

Thank you for the instructions , I was able to draft up the code for you to try.

[cred_generic_field type='radio' field='modified']
{
"default":["no"],
"persist":1,
"options":[{"value":"yes","label":"yes"},{"value":"no","label":"no"}]
}
[/cred_generic_field]

jQuery( ".js-wpt-credfile-delete " ).click(function() {
  jQuery('input:radio[name=modified]').filter('[value=yes]').prop('checked', true);
});

The field above is the generic radio field that will be selected if the user modifies the image field. I did this based on the user pressing the x button beside the image.

This will trigger the field to be selected to a yes.

Now all that is needed is to setup the notification based on the modified radio field and you should get your desired results.

Thanks,
Shane

#1244713
notification_email_fotos2.jpg

So you created a genetic field in the form instead of using one of the two custom checkbox field I created for you? Why?

Also I cannot select the genetic field in the dropdown menu for field condition in the notification section (see image).

#1244749

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Felipe,

I saw what you did but the code wasn't working for the hidden fields. So I created this radio button as a test.

What you can do is to create the radio buttons with Yes or No and I can add it to the form.

I will need to adopt the code to work with this but its just changing the names and doing the test to see if the value changes.

Checkboxes prove a little difficult to handle so please change it to the radio buttons with Yes and No.

Thanks,
Shane