Skip to:
Content
Pages
Categories
Search
Top
Bottom

"simply" trying to filter the bp_ajax_querystring via Ajax


  • haruki_jitsunin
    Participant

    @haruki_jitsunin

    This is proving to be much more difficult than it would originally seem.

    So, I created a php function that loops through all my members and successfully finds only the members that I want it to find. I have gotten the function to return just the user IDs. However, I have tried several times (unsuccessfully) to limit the BP ajax querystring.

    I could go over the laundry list of everything I’ve tried, but it gets REALLY long.

    What I am wondering is:
    if given an array(or comma separated list) of member IDs, is it possible to filter the querystring via Ajax? Let’s pretend that I have cookies I have set myself and am able to read using a basic function in the bp-custom.php file already (because I do). Hell, let’s pretend that I’m able to formulate the string:
    "type=active&action=active&include=".$list_of_members."&page=1"
    where $list_of_members is a comma separated string of member ids that I want to find.

    I’ve tried simply editing the bp_dtheme_ajax_querystring function in Ajax.php so that $query_string calls my function and returns the string I put in code above… without any success..

    This has been quite an extensive problem for me. Any help would be greatly appreciated.

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

  • haruki_jitsunin
    Participant

    @haruki_jitsunin

    Also, let’s pretend I can post a request to Ajax.php. What I’m looking for, specifically, is what type of ajax function I should be using as the standard ones don’t seem to like ANY customization.


    haruki_jitsunin
    Participant

    @haruki_jitsunin

    What it looks like is that the bp_dtheme_ajax_querystring should take a variable $query_string, which it grabs from the cookies and applys a filter to the bp_ajax_querystring. Every time I try to create a function that ACTUALLY filters it with an actual $query_string, it doesn’t work. I’ve printed out the variable and as far as I can tell, my query string is identically structured to the one the function automatically creates, but for some reason it won’t take an “include” or even “exclude” argument.


    modemlooper
    Moderator

    @modemlooper

    function special_bp_dtheme_ajax_querystring( $query_string, $object ) {
    
        /* Now pass the querystring to override default values. */
        $query_string .= '&type=active&action=active&include='. $list_of_members .'&page=1';
    
        return $query_string;
    }
    
    function my_ajax() {
        add_filter( 'bp_dtheme_ajax_querystring', 'special_bp_dtheme_ajax_querystring', 11, 2 );
    }
    add_action( 'wp_ajax_my_ajax', 'my_ajax' );
    

    Read up on ajax and WordPress on how to safely and properly use it. https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action)

    I wrote in the query string but you can send it through the ajax call.


    haruki_jitsunin
    Participant

    @haruki_jitsunin

    That was perfect! It worked like a charm… I think I wasn’t adding an action to filter. I got the two confused… filters… actions… still wrapping my head around this. It doesn’t help that buddypress is surprisingly undocumented. I’m glad that there are superheroes like you around to save the day!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘"simply" trying to filter the bp_ajax_querystring via Ajax’ is closed to new replies.
Skip to toolbar