Meta Box
Support Forum
Support › MB Custom Table › Slashes issue
Hi guys,
How can we strip slashes from fields before they're displayed by metabox?
Cheers,
Will
Hello Will,
Which field type you are using? Let me try to reproduce the issue on my local site.
The Text field in this case.
Thanks,
Hello,
I do not see that issue on my local site, screenshot https://monosnap.com/file/G6nSExPrhxmRCk6HJqPoyejwh4YKdM even with a subfield inside a group.
You can try this again with a fresh install of WordPress and Meta Box plugins to see how it goes.
Hi
I suppose what I'm asking is if slashes are present in the DB data should MB be stripping them before displaying the data in a input field? It is currently not happening at my end.
Worth noting that this data is in a custom table and for a custom model not, as in your example, the postmeta table.
Thanks in advance. Will
If you want to stripe the slashed from the field value after adding in the admin area, please create a custom sanitize callback. The default sanitize function of WordPress does not support striping the slashes, please follow the documentation https://developer.wordpress.org/reference/functions/sanitize_text_field/ https://docs.metabox.io/sanitization/#custom-sanitize-callback
If the value is inserted into the DB from another source like Rest API, you can stripe the slashes from the value before inserting it into the DB.
I've tested with a custom table and see the same results.