please read this:
If you wanted to be superman for a day all you had to do was ask! 🙂 Thanks danbp!
Actually, that brings me to another issue it seems…
Call to undefined function xprofile_get_field_data()
Did that function change? I’m currently using it on a steam community website to pull steam ID’s so I can poll steam and display a stream widget on the user’s profile page.
You’re probably calling xprofile_get_field_data()
too early.
Wait until BP is loaded, use the bp_ready
hook.
So… make sure this is right…
function doProfileStuff()
{
echo xprofile_get_field_data('stuff');
}
add_action('bp_ready', 'doProfileStuff');
I guess the question is “how” to hook into it or do you use bpready directly in place of add_action ?
May I ask for an example.. If I see how it is used, I can run with that being as there seems to be slim documentation on how bp_ready is used.
You need to pass additional fields – and in the correct order.
http://hookr.io/functions/xprofile_get_field_data/
This is what I have (I shorted the above code as an example of how to hook into bp_ready)
function executeSteamID()
{
$steam64id = xprofile_get_field_data('Steam64 ID', get_current_user_id());
$steamUser = xprofile_get_field_data('Steam User', get_current_user_id());
$steamCache = xprofile_get_field_data('Steam Cache', get_current_user_id());
// we now do stuff with the above data.. then echo it
}
How would I hook into bp_ready in that situation?
** Yes I’m shamelessly using a hidden xprofile field to store cache data 😛
Use the same hook in the same way as you did above.
Nope. The hook does work, because profiler says the function is called later now, but the function still doesn’t seem to exist and throws the undefined function exception.
Also, other plugins do as well including gears which is used by theme authors such as myself for allowing users to easily add elements to a website from buddypress.
Does the profiler show that BP is loaded before you call your function?
If not, then it will fail.
Try placing your function in bp-custom.php
Thanks Shane! I’ll give this a shot when I get back to home this evening and let you guys know how it works out. I’m afraid the little profile I made doesn’t do any sorts of compares, it just lets me know if it is loaded before or after certain other hooks like init, the_content and such.. I’ll have to reopen that and add bp_load and get a better idea of where it loads to buddypress though.
My I make a request, though, developer to developer 😛 This seems to have broken a lot of plugins and I like to say I follow the methods of WordPress to the letter without getting hacky :P. If changes like this are made, can we still preserve a method of backward compatibility? The profile info, for instance shouldn’t matter much when it loads, so long as the BP class is loaded, which means, I guess what I’m saying is I’m drawing a blank to what it would be that would require the xprofile fields to be dropped to such a low load order that it doesn’t initialize with the plugin class init.