Skip to:
Content
Pages
Categories
Search
Top
Bottom

Problems with filtering the activity stream


  • IdleWanderer
    Participant

    @idlewanderer

    Hi there,

    For a while back I got lots of help in this forum on how to filter the activity stream for specific pages using parse_args. It has been great so far, but I have come across a small issue with some of the terms I want filtered.

    Basically, this is what I want and what am doing so far:
    If a user writes about a specific species of animal, whatever the user wrote will come up on the activity stream for that particular species, as long as the name of the species is mentioned. Now, this I can do (thanks to help in here), but a few animals have a species name with an apostrophe in it, and that’s where my problem arises.

    Here’s an example of what I want done:

    function my_bp_activities_search_term_on_page_3431( $retval ) {
        // Add search term for correct page
        if ( is_page(3431) ) {
             $filter_query[] = array(
            'relation' => 'OR',
            array(
                'column'  => 'content',
                'value'   => 'keast's tube-nosed fruit bat',
                'compare' => 'LIKE'
            ),
            array(
                'column'  => 'content',
                'value'   => 'keast's tube-nosed bat',
                'compare' => 'LIKE'
            ),
            array(
                'column'  => 'content',
                'value'   => 'nyctimene keasti',
                'compare' => 'LIKE'
            ),
        );
        $retval['filter_query'] = $filter_query;
        }
     
        return $retval;
    }
    add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activities_search_term_on_page_3431' );

    Of couse, this gives me an errer. I looked the issue up on google, and it seemed that the problem would be fixed by writing it like this:

    'value' => 'keast\'s tube-nosed fruit bat',

    Now, when doing this I no longer get the fatal error, but if I write “keast’s tube-nosed fruit bat” in the activity stream, it won’t show where it should.

    So, how can I solve this and have “keast’s tube-nosed fruit bat” show?

    Thanks!

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

  • Henry Wright
    Moderator

    @henrywright

    So, how can I solve this and have “keast’s tube-nosed fruit bat” show?

    You can use double quotes instead of single quotes to wrap the string of text. So for example:

    'value' => "keast's tube-nosed fruit bat",


    IdleWanderer
    Participant

    @idlewanderer

    Thanks, but I’ve also tried that already. No error, but nothing shows up either..


    IdleWanderer
    Participant

    @idlewanderer

    I even tried now to wrap everything in double quotes instead of single quotes, making it look like this (and continued to the end):

    function my_bp_activities_search_term_on_page_3431( $retval ) {
        // Add search term for correct page
        if ( is_page(3431) ) {
             $filter_query[] = array(
            "relation" => "OR",
            array(
                "column"  => "content",
                "value"   => "keast's tube-nosed fruit bat",
                "compare" => "LIKE"
            ),

    The function retained its functionality, but the term with the single quote still would not show..


    Henry Wright
    Moderator

    @henrywright

    In that case, this could be a bug. It seems the apostrophe isn’t being handled properly upstream. Can you open a ticket for this on Trac?

    https://buddypress.trac.wordpress.org/


    IdleWanderer
    Participant

    @idlewanderer

    Thanks, I’ll try doing that.

    However, I can’t seem to log in to Trac.. It asks me to login, and when I do, nothing happens.. I just get sent back to the “you need to login” page.


    Henry Wright
    Moderator

    @henrywright

    I just tried (with the same details I use here in the forum) and was able to log in successfully. Are you still having trouble?


    IdleWanderer
    Participant

    @idlewanderer

    Yes, still having issues logging in. Also tried another browser, but got the same issue.


    Henry Wright
    Moderator

    @henrywright

    That’s strange! The credentials to use are the same as those you use here in the forum so if you can log in here then you should be able to log in there. Can you try clearing your cookies?


    IdleWanderer
    Participant

    @idlewanderer

    Hm.. No matter what I do, it doesn’t seem like I can get into Trac.. I get no error when trying to login (such as telling me that the username or password is wrong), it just takes me back to the login page. I get the same even on my phone..


    Henry Wright
    Moderator

    @henrywright

    Can you log in to wordpress.org?


    IdleWanderer
    Participant

    @idlewanderer

    I am fairly certain I already answered this.. Weird..

    Anyway, I managed to get in eventually. It seems the wrong password was saved in my browser. I got a new from WordPress and I finally got in. The ticket is in now, so let’s see if they do anything about it.


    Henry Wright
    Moderator

    @henrywright

    I got a new from WordPress and I finally got in

    Great 🙂

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