Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get “Edit Cover Image” link outside of Buddypress page


  • invest0r7
    Participant

    @invest0r7

    Hi all,

    I have the following link that I’m trying to get to display on a page outside of Buddypress:

    <?php 
    echo bp_get_members_component_link( 'profile', 'change-cover-image' );
    ?>

    But it’s not working, is there a particular global I need to declare? It’s on a non-Wordpress page but “wp-blog-header.php” is included on the page.

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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.


    invest0r7
    Participant

    @invest0r7

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar