The reason that it doesn’t work – it requires to be placed on a user BuddyPress profile page.
It uses bp_displayed_user_domain()
function to generate the link, as there is no user on your custom page (it’s not BuddyPress or even WordPress) – bp_get_members_component_link
function produces nothing.
There is no easy fix. You will need to create that link manually by retrieving somehow user domain (link to profile) of a desired user.
Well actually bp_loggedin_user_domain();
and other functions are working on this particular page, so I’m not sure what’s particularly wrong with this one.
I can echo people’s profile URL with: <?php echo bp_loggedin_user_domain(); ?>
This also works:
<?php
global $bp;
$message_inbox_count = messages_get_unread_count();
if ($message_inbox_count > '0') {
echo '<span>'.$message_inbox_count.'</span>';
} ?>
So I’m not sure why the above would work but not bp_get_members_component_link();
?
messages_get_unread_count()
uses info about logged in user.
bp_get_members_component_link()
– about displayed user.
Logged in user – is based on cookies.
Displayed user – is based on the page user currently viewing.
That’s why messages_get_unread_count()
works everywhere when user is logged in, while bp_get_members_component_link()
will work only on URL like http://example.com/members/invest0r7