Support » Plugins » Hacks » Prevent WP adding slashes to POST

  • I have a form in the admin area for my plugin, and when a value is submitted that contains single quotes, double quotes, or slashes, wordpress adds slashes to escape them in the POST.

    e.g.
    “Visitor\Country”
    becomes
    \”Visitor\\Country\”

    How do I stop the slashes from being added?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try stripslashes after you retrieve the content from $_POST.

    Like this:

    $some_content = $_POST[ 'some_content' ];
    $some_content = stripslashes( $some_content );

    Bam. Problem solved. 😀

    Thanks, that works nicely.

    Is there any way I can prevent WP from adding the slashes in the first place? It just seems a bit inefficient for WP to add slashes to all the POST, then for me to have to remove slashes.

    Ignore this message

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Prevent WP adding slashes to POST’ is closed to new replies.