Navigation überspringen

[Gelöst] Backslashes added on save in cred form

This support ticket is created vor 1 Jahr, 9 Monaten. 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)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von amandaD vor 1 Jahr, 9 Monaten.

Assistiert von: Luo Yang.

Author
Artikel
#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: versteckter Link

1) Dashboard-> Toolset-> Settings-> Custom codes:
versteckter Link

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:
versteckter Link

It works fine.

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

#2603977

Thanks so much - that fixed my issue.