Question

I'm looking to add a link to buddypress profiles on author pages - the page that displays all posts by an individual author. The link would need to direct to the individuals buddypress profile, so need to call for author meta and replace the normal author link with bp_core_get_user_domain to grab the buddypress profile.

I have a description box at the top of the author page, with links to their social media accounts (see below) and would like to add this new link in line with that.

Any help would be appreciated.

<p class="desc"><?php echo esc_html( $curauth->description ); ?></p>
                <p class="follow">
                <?php
                    if ( get_the_author_meta('user_url', $curauth->ID) ) echo '<a class="home" href="'. esc_url(get_the_author_meta('user_url', $curauth->ID)) .'"><i class="fa fa-home"></i></a>';
                    if ( get_the_author_meta('facebook', $curauth->ID) ) echo '<a class="facebook" href="'. esc_url(get_the_author_meta('facebook', $curauth->ID)) .'"><i class="fa fa-facebook"></i></a>';
                    if ( get_the_author_meta('twitter', $curauth->ID) ) echo '<a class="twitter" href="'. esc_url(get_the_author_meta('twitter', $curauth->ID)) .'"><i class="fa fa-twitter"></i></a>';
                    if ( get_the_author_meta('gplus', $curauth->ID) ) echo '<a class="google-plus" href="'. esc_url(get_the_author_meta('gplus', $curauth->ID)) .'"><i class="fa fa-google-plus"></i></a>';
                    if ( get_the_author_meta('linkedin', $curauth->ID) ) echo '<a class="linkedin" href="'. esc_url(get_the_author_meta('linkedin', $curauth->ID)) .'"><i class="fa fa-linkedin"></i></a>';
                ?>
                </p>
            </div>
            <!-- end:author-box -->
Was it helpful?

Solution

Did you try using bp_core_get_user_domain() ?

For example:

echo '<a class="linkedin" href="'. bp_core_get_user_domain( $curauth->ID ) .'">Profile</a>'
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top