Skip to:
Content
Pages
Categories
Search
Top
Bottom

bp_filter_request: What does it do and how does it work?

  • Avatar of Arx Poetica
    Arx Poetica
    Participant

    @arxpoetica

    Can somebody help me pick this thing apart w/ a fork? I’ve been trying to parse it on my own with some success. I realize it has a global scope, can be called globally, and can be fed certain variables to get different ajax results.

    So, for example, from the members directory page, when a user clicks on one of the pagination items, bp_filter_request handles a certain number of variable that are posted to “http://arxnew.tld/wp-load.php” (ajaxurl is the variable). But how are these variable processed (wp-load.php doesn’t seem to be doing the handling — where is this taking place?)

    Some of the variables posted, for example, might look like this:

    action: “members_filter”,
    ‘cookie’: “wp-settings-1%3Dm5%253Do%2526m9%253Dc%2526m0%253Do%2526m8%253Dc%2526m7%253Dc%2526m6%253Dc%2526m4%253Dc%2526m3%253Dc%2526m2%253Dc%2526m1%253Dc%3B%20wp-settings-time-1%3D1268530134%3B%20bp-members-filter%3Dnewest%3B%20bp-members-scope%3Dall%3B%20bp-activity-oldestpage%3D1″,
    ‘object’: “members”,
    ‘filter’: “newest”,
    ‘search_terms’: “Search anything…”,
    ‘scope’: “all”,
    ‘page’: 2,
    ‘extras’: null

    But what does it all mean, and how can I figure out what the different responses will be based on input? Very confused…

Viewing 4 replies - 1 through 4 (of 4 total)
  • Avatar of Boone Gorges
    Boone Gorges
    Keymaster

    @boonebgorges

    Strictly speaking, wp-load.php is the handlet for all AJAX calls, in virtue of the WP AJAX API.

    The key to finding the function that processes data is to look in bp-themes/_inc/ajax.php for an add_action hooked to wp_ajax_[youraction]. For instance, since in this case the action being passed is members_filter, search for wp_ajax_members_filter, and the function hooked to it.

    Avatar of Arx Poetica
    Arx Poetica
    Participant

    @arxpoetica

    Brilliant! Found and served. :)

    Now… how does one hook into that hook, if that makes any sense. In this case, for example, since the action is wp_ajax_members_filter, is there a way to tag on (hook) extra content loaded (of my own making) that will return in the response? Am I making sense?

    In other words, on the members directory page, when the user clicks navigation, I’m trying to load extra info about each user, and “hook” it into the same ajax call, so that it’s relevant to the content being loaded. I might have an idea how to do it (hoping it can be done in my own functions.php page), but any pointers are also welcome. Glad this answer came so quickly, btw.

    Avatar of Arx Poetica
    Arx Poetica
    Participant

    @arxpoetica

    Actually, figured out a much simpler and easier way to hook into what I need…little did I realize that the groups-loop.php and members-loop.php pages each had actions I could hook into –> right exactly where I needed them. Sharing here for the benefit of others, this is what I’ve loaded in functions.php in my child theme:

    function load_directory_panel() {
    locate_template(array(“directory-panel.php” ), true);
    }
    add_action(‘bp_after_directory_members_list’, ‘load_directory_panel’);
    add_action(‘bp_after_groups_loop’, ‘load_directory_panel’);

    Doing something roughly like this, though I may break the groups/members panel pages out into separate pages for separate content. But that’s the gist of it. Yay!

    Avatar of Boone Gorges
    Boone Gorges
    Keymaster

    @boonebgorges

    Ha, that is a lot easier! Thanks for sharing @arxpoetica

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

You must be logged in to reply to this topic.