Skip to content

Commit 86644d3

Browse files
committed
Ensure that 'Site Dashboard' link is contextually correct when viewing another's profile.
See cuny-academic-commons/commons-in-a-box#544.
1 parent beeb5f0 commit 86644d3

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

lib/group-funcs.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,8 +2384,23 @@ function openlab_bp_group_site_pages( $mobile = false ) {
23842384

23852385
?>
23862386

2387-
<?php /* Abstract the displayed user id, so that this function works properly on my-* pages */ ?>
2388-
<?php $displayed_user_id = bp_is_user() ? bp_displayed_user_id() : bp_loggedin_user_id(); ?>
2387+
<?php
2388+
/*
2389+
* Determine the current user ID.
2390+
* 1. On a user page, use the displayed user ID.
2391+
* 2. On portfolio groups, use the ID of the user to whom the portfolio belongs.
2392+
* 3. Otherwise, use the logged-in user ID.
2393+
*/
2394+
$displayed_user_id = bp_loggedin_user_id();
2395+
if ( bp_is_user() ) {
2396+
$displayed_user_id = bp_displayed_user_id();
2397+
} elseif ( cboxol_is_portfolio() ) {
2398+
$group_owner_id = openlab_get_user_id_from_portfolio_group_id( $group_id );
2399+
if ( $group_owner_id ) {
2400+
$displayed_user_id = $group_owner_id;
2401+
}
2402+
}
2403+
?>
23892404

23902405
<div class="sidebar-block group-site-links <?php echo esc_html( $responsive_class ); ?> ">
23912406

0 commit comments

Comments
 (0)