Skip to:

backslash apostrophe bug

  • MBV


    I realize this bug has been discussed and troubleshooted many years ago… believe it or not I’m getting this issue right now.

    Most of the time, not quite sure if it’s all the time, when a user posts in activity feed, every apostrophe is preceded by a backslash. For example, It’s becomes It\’s

    When as admin I edit their comment, it does not show the backslash and when saved it does not show. But on page refresh it shows it again. Can only seem to remove it by editing database directly and removing the backslash from the content.

    Not sure but I just seemed to notice that a new comment less than maybe about 24 hours seems to display okay. But then after about 24 hours, that same comment now displays backslashes with the apostrophes.

    I’ve disabled magic_quotes_gpc, magic_quotes_sybase, magic_quotes_runtime.

    I’m now re-trying out the following code just in case I gave up on it too soon.

    //Attempt to strip backslashes
    add_filter( 'get_topic_title', 'strip_the_title_slashes', 20, 2);
    function strip_the_title_slashes( $title, $id ) {
    return stripslashes( $title );
    add_filter( 'get_post_text', 'strip_the_text_slashes', 20, 2);
    function strip_the_text_slashes( $text, $id ) {
    return stripslashes( $text );

    Any other suggestions, please?

Viewing 2 replies - 1 through 2 (of 2 total)

  • David Cavins


    Hi @mbv-

    The data should be slashed on the way into the database. When you call the activity content using bp_get_activity_content_body(), many filters are applied, including stripslashes_deep here:

    If you’re displaying activity using an activity loop (like BuddyPress does in its default theme parts), then the results are as expected. If you’re accessing the data some other way, you’re going to need to apply the needed filters to it. Check out the link above to see all the filters that applied to bp_get_activity_content_body.



    Hi @dcavins
    Thank you for your reply! I realized that after deleting them that the backslashes were actually meant to be there in the database….Oops!

    I have now stopped deleting them, hopefully it won’t cause any issues for the ones that are deleted.

    The problem with backslash is ongoing. After re-adding that code, it seems to be a little less, though it could just be part of the randomness of it.

    The activity I refer to is just the standard activity on the /activity page. Seemingly at random, the filters do not apply and the backslash is visible on the front end for some posts. Currently now it’s only happening for update posts and posts on other person’s wall.

    As such, not sure how to go about troubleshooting this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar