WordPress.org

Ready to get started?Download WordPress

Forums

Prevent WP adding slashes to POST (4 posts)

  1. djeyewater
    Member
    Posted 1 year ago #

    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?

  2. Spencer Cameron
    Member
    Posted 1 year ago #

    Try stripslashes after you retrieve the content from $_POST.

    Like this:

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

    Bam. Problem solved. :D

  3. djeyewater
    Member
    Posted 1 year ago #

    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.

  4. djeyewater
    Member
    Posted 1 year ago #

    Ignore this message

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags