Saltar navegación

[Resuelto] Backslashes added on save in cred form

This support ticket is created hace 1 año, 8 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.

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

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por amandaD hace 1 año, 8 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#2603311
Screenshot 2023-05-05 132110.png

Every time my user save's their location in a CRED form, apostrophes get double escaped.
I have a location field. I expect to see: 68 O'Connell Street
Instead, I see: 68 O\\\\'Connell Street

More and more backslashes get added every time there is an edit.

The forums talk about similar problems in the CSS and JS sections, but those were apparently resolved 4 years ago?

#2603901

Hello,

I can duplicate the same problem, will escalate this issue.

Currently, please try to remove the extra Backslashes with cred_save_data actions, see below test site:
Login URL: enlace oculto

1) Dashboard-> Toolset-> Settings-> Custom codes:
enlace oculto

Add one item, with below codes:

add_action('cred_save_data', function($post_id, $form_data){
	if($form_data['id'] == 23){
      	$location = get_post_meta($post_id, 'wpcf-location', true);
      	update_post_meta($post_id, 'wpcf-location', stripcslashes($location));
    }
}, 99, 2);

Please replace 23 with your post form ID, replace "location" with your custom address field slug

2) Test it in frontend:
enlace oculto

It works fine.

More helps:
enlace oculto
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

#2603977

Thanks so much - that fixed my issue.