| | #1 |
| Grouchy Old Geezer War Room Member Join Date: 2006 Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 673
Thanks: 279
Thanked 62 Times in 47 Posts
|
I am creating a wordpress multiser or network site with forms on each blogs dashboard where the admin can enter content. There are two textare boxes and one text input box in the form and it is being saved as post metadata using a _POST action. What would you suggest I use to sanitize the data that is being saved? And, where would this sanitizing function go? Thanks, |
| "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice." Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781) | |
| |
| | #2 |
| Software Product Creator War Room Member Join Date: 2012 Location: NL => Thailand
Posts: 452
Thanks: 42
Thanked 164 Times in 93 Posts
Blog Entries: 5 |
Check out PDO it auto sanitizes (when used correctly!!)
|
| Recurring Proven SEO Business Model Rent Out Your (Local) Sites and YT vids Give you AD Funnel Super Power! ADConnect.io - Lower CPC. Sky-Rocket Conversions!! | |
| |
| The Following User Says Thank You to SteveSRS For This Useful Post: |
| | #3 |
| Grouchy Old Geezer War Room Member Join Date: 2006 Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 673
Thanks: 279
Thanked 62 Times in 47 Posts
|
Being one old non-coder, PDO looks to be way over my head. I was reading the Wordpress Codex for update_post() and noted that it runs any submission through kses. Does update_meta() run data submitted through kses? |
| "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice." Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781) | |
| |
| | #4 | |
| VIP Warrior War Room Member Join Date: 2007 Location: Caldwell, Idaho, USA.
Posts: 1,967
Thanks: 1,024
Thanked 2,043 Times in 1,183 Posts
|
This page: Data Validation « WordPress Codex discusses data validation in WP. There are a number of WP functions that will do what you need. Also, you should check the docs on WP nonces: WordPress Nonces « WordPress Codex. Your form processing function verifies the nonce to ensure that whatever submitted the form data has the authority to do so. Also, it sounds like you're trying to create a dashboard widget? If so, this page: Dashboard Widgets API « WordPress Codex might help.
| |
| |
| The Following 2 Users Say Thank You to SteveJohnson For This Useful Post: |
| | #5 |
| Grouchy Old Geezer War Room Member Join Date: 2006 Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 673
Thanks: 279
Thanked 62 Times in 47 Posts
|
Thanks Steve, I've been struggling, trying to figure out what to do and am wondering if I could create a function and have the sanitize_meta function clean up things for me. Seems that is called when the update_meta function is called. What you think? |
| "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice." Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781) | |
| |
| | #6 |
| VIP Warrior War Room Member Join Date: 2007 Location: Caldwell, Idaho, USA.
Posts: 1,967
Thanks: 1,024
Thanked 2,043 Times in 1,183 Posts
|
The sanitize_meta function is just an empty hook, it doesn't do anything on its own. You build your own sanitizing filter (function) for a specific meta key, and run it by adding the filter to the sanitize_meta function. You would use this kind of filter most often when you're needing to validate/sanitize a custom field that a user would enter. In your case, it would be easier to just build your filter into the function that saves the meta data. Let's say you want to allow only the limited HTML that is allowed in a comment. It's as simple as this: $meta_data = wp_kses_data( $_POST['meta_data'] ); update_post_meta( $post->ID, 'meta_key', $meta_data ); ( Function Reference/wp kses data « WordPress Codex ) It's kind of difficult to guide you without seeing exactly what you're doing. |
| |
| The Following User Says Thank You to SteveJohnson For This Useful Post: |
| | #7 |
| Svetoslav Marinov (SLAVI) Join Date: 2011
Posts: 211
Thanks: 20
Thanked 27 Times in 26 Posts
|
For my fields I use strip_tags and trim to make sure HTML tags are removed. Is it text content that goes in the text fields? |
|
Are you using WordPress? Have you tried qSandbox yet?
| |
| |
| The Following User Says Thank You to lordspace For This Useful Post: |
| | #8 |
| Software Product Creator War Room Member Join Date: 2012 Location: NL => Thailand
Posts: 452
Thanks: 42
Thanked 164 Times in 93 Posts
Blog Entries: 5 |
lordspace that is def not enough for insertion in a database...
|
| Recurring Proven SEO Business Model Rent Out Your (Local) Sites and YT vids Give you AD Funnel Super Power! ADConnect.io - Lower CPC. Sky-Rocket Conversions!! | |
| |
| The Following User Says Thank You to SteveSRS For This Useful Post: |
| | #9 |
| VIP Warrior War Room Member Join Date: 2007 Location: Caldwell, Idaho, USA.
Posts: 1,967
Thanks: 1,024
Thanked 2,043 Times in 1,183 Posts
| |
| |
| The Following User Says Thank You to SteveJohnson For This Useful Post: |
| | #10 | |
| Grouchy Old Geezer War Room Member Join Date: 2006 Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 673
Thanks: 279
Thanked 62 Times in 47 Posts
|
I tried posting my code in here, but it appears I can't do the bbcode for code. Okay if I PM you and send what I think is the pertinent code either privately or in an email? I'm not sure whether to put the sanitize function in the functions.php or the include file. Take a look at the code and you'll see why ... one of the things I do is switch between blogs a bit. | |
| "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice." Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781) | ||
| |
| | #11 | |
| Grouchy Old Geezer War Room Member Join Date: 2006 Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 673
Thanks: 279
Thanked 62 Times in 47 Posts
|
numberic? I need to learn to spell when it is four hours past my old geezer bedtime. | |
| "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice." Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781) | ||
| |
| | #12 | |
| VIP Warrior War Room Member Join Date: 2007 Location: Caldwell, Idaho, USA.
Posts: 1,967
Thanks: 1,024
Thanked 2,043 Times in 1,183 Posts
|
| |
| |
| The Following User Says Thank You to SteveJohnson For This Useful Post: |
| | #13 | |
| Grouchy Old Geezer War Room Member Join Date: 2006 Location: Ellijay, GA, USA. (Talk about being in the woods!)
Posts: 673
Thanks: 279
Thanked 62 Times in 47 Posts
|
Files sent. | |
| "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice." Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781) | ||
| |
|
| Bookmarks |
| Tags |
| advice, needed, security |
| |