AJAX changes in BuddyPress 1.6
In a recent change, we’ve updated where the Default Theme’s ajaxurl variable points to; it now points to admin-ajax.php instead of wp-load.php. If you are a BuddyPress plugin author who uses this, update your plugin now to ensure compatibility with BuddyPress 1.6.
Since the early days, the Default Theme has output a javascript variable called “ajaxurl” into the page, and it contained the URL to wp-load.php, which is used early in the WordPress loading bootstrap. Likewise, in WordPress itself, when you’re at a page inside the /wp-admin/ part of the site, it also sets a variable called ajaxurl; rather than pointing to the same place as BuddyPress, the URL it contained was to admin-ajax.php.
Why the difference? BuddyPress was doing it wrong; admin-ajax.php works just fine from the front of your site. We’ve figured out a way to guarantee backwards compatibility for any combination and version of BP Default that you might be using, so nothing will break when you upgrade to BuddyPress 1.6.
However, in situations where a site uses 1.6′s Default Theme as the active theme, or as a parent theme, or when _inc/ajax.php is copied into another theme, if a third-party BuddyPress plugin makes use of BuddyPress’ ajaxurl, your plugin’s AJAX may break. In a nutshell, unless you terminate script output through exit() after your AJAX handler does its stuff, WordPress will suffix your output with a zero (details on the WP Codex), and this may have undesired results.
Plugin authors should implement this change in their plugins now. It’s a backwards compatible change, and will work on all current versions of BuddyPress, and help you avoid bug reports after 1.6 is released.
slaFFik 10:06 pm on May 1, 2012 Permalink |
Better late than never.
Thanks!
Daniel 6:03 pm on May 6, 2012 Permalink |
So what plugins are currently affected and how do we go about fixing them?
Paul Gibbs 10:52 am on May 7, 2012 Permalink |
We haven’t audited all of the BuddyPress plugins to see which are affected. The most trivial fix is for those plugins’ authors to simply exit() after they’ve finished handling the request.
kris 1:31 pm on May 30, 2012 Permalink
Hi Paul,
sorry for spamming, please feel free to delete this comment (after you’ve read it
I think there is a major flow in BuddyPress, the way it works ‘members’ and memberships
as it is now, it helps spammers.
I do not think there should be a /members/ slug and listing all members.
(maybe just for admin and moderators)
but if it was scrapped, and reinvented to just use ‘find friends’ box, it could probably save development resources too..
the way people make friends, should be rather by searching for friends (username or email) I guess, that’s Facebook way..
and hopefully, to prevent spammers, a useful feature, would be to limit how many friends per day/hour etc.. people can make
similarly, how many posts/updates that users could make per minute/hour
we have almost 200k members, and fighting spam (real humans posting..) is a pain in the ..s
we had to turn off ‘friendships’ and private messaging feature,
and turning off and on, activity updates..
so there is not much left from original BuddyPress that we were so excited about
I do hope new BuddyPress 1.6 will be shining though, and looking forward to it!! thanks for your great work,
Kris
ben 1:15 pm on August 12, 2012 Permalink |
How can I remove the automatic hyperlink on each member profile data? it is very anoying
Thanks.
Jon 1:52 am on August 28, 2012 Permalink |
We’re having huge problems with 1.6.1 and AJAX on a fresh install. We’re using BP Template pack that says it’s compatible to 1.5x for our theme which works great until some uses anything that relies on AJAX. (So it doesn’t work at all. LOL!) Might you have any advice for a non-programmer stuck with a freaked out install of BP? Figured I’d ask.
Paul Gibbs 12:47 pm on August 28, 2012 Permalink |
Best to ask on the buddypress.org support forums rather than this post, please. When you do, if you can share a link to your site if public, that would let us take a look. Ta