Skip to content

Instantly share code, notes, and snippets.

@khoand0000
Last active August 29, 2015 14:25
Show Gist options
  • Save khoand0000/2ae32548f8fdd8d5b34a to your computer and use it in GitHub Desktop.
Save khoand0000/2ae32548f8fdd8d5b34a to your computer and use it in GitHub Desktop.
note when saving data from $_POST in wordpress (wp_magic_quotes).

Because wordpress call wp_magic_quotes() to add slashes before we use $_POST or $_GET ($_REQUEST), so if you save data from $_POST or $_GET ($_REQUEST) in wordpress,

  • single value, do
$username = stripslashes($_POST['username'])
  • or all of values, do
$_POST = stripslashes_deep($_POST);

before calling $wpdb->insert()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment