Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This problem has been bugging me for couple of days. After adding a new subnav, I got the following error when trying to use the drop down groups filter: 404 Not Found – mysite.com/wp-admin/admin-ajax.php”

Basically I wanted to add a new subnav items under a member’s main nav “groups”. Currently there are two subnav items there: “memberships” and “invitations”. I would like to add my own subnav item called “My Customized Groups”. When this subnav is clicked, it will show groups of certain feature.

Okay the first step is to create a new subnav items. I did it by adding the following code to my functions.php

//add new subnav items
bp_core_new_subnav_item( array(
'name' => __( 'My Customized Groups', 'buddypress' ),
'slug' => 'my-custom-groups',
'parent_url' => $groups_link,
'parent_slug' => $bp->groups->slug,
'screen_function' => 'groups_screen_my_custom_groups',
'position' => 20
));

To make sure my subnav works, my screen_function “groups_screen_my_custom_groups” is a exactly copy of the default “groups_screen_my_groups”. Now the subnav is added, and groups loop show up correctly. But when I select the drop down filter ( “last active”, “most members”, “newly created”, etc), the following error shows up: 404 Not Found – mysite.com/wp-admin/admin-ajax.php”

if I set this new subnav as the default by adding the following code in functions.php

$args = array(
'parent_slug' => $bp->groups->slug,
'screen_function' => 'groups_screen_my_custom_groups',
'subnav_slug' => 'my-custom-groups'
);

bp_core_new_nav_default($args);

Then the ajax works correctly for my-custom-groups, but it doesn’t work for other subnav items anymore. It seems ajax only works for the default subnav? This is strange.

It must be something minor, but I still can’t figure out what’s been wrong after searching everywhere for two days.

Thanks in advance for the help.

Wordpress version: 3.4.2 buddypress version: 1.6.1

share|improve this question
    
I have a very similar problem. I get the same 404 error but if i check the response all the data is there. So admin-ajax.php is handling right the call but im not sure why is returning a 404 responde header –  chifliiiii Feb 22 '13 at 12:05
add comment

1 Answer

Is i commented previously im having the same error. I dont know what it causing it but i found a workaround for it.

Im using a modified version (by me) of the plugin buddypress-groups-tags which allows me to create categories for groups. That plugin uses bp_core_new_subnav_item to be able to use slugs like : http://local.dev/groups/category/teachers/

My problem was that inside that url in the activity loop, the more link was getting a 404 responde header error on admin-ajax.php. If i check the response content all the activity data was there. So im not sure what is causing the problem.

To solve it i added a function that will return a status header of 200 when the ajax call is triggered. In my case i needed for "get_older_updates" action but i suppose you can use it for any other action defined at /bp-themes/bp-default/_inc/ajax.php:27

add_action( 'wp_ajax_activity_get_older_updates', 'bp_dtheme_activity_template_loader2' );
add_action( 'wp_ajax_nopriv_activity_get_older_updates', 'bp_dtheme_activity_template_loader2' );

function bp_dtheme_activity_template_loader2(){
    if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'activity_get_older_updates')
    {
        status_header( 200 );
    }
}   

Hope it helps!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.