Opened 7 years ago
Closed 7 years ago
#7585 closed defect (bug) (worksforme)
Issues with $has_access
Reported by: | udarmo | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Core | Keywords: | |
Cc: | bn.bhandari90@…, inna.zengin@… |
Description
Hi,
I’m using BP 2.9 and WP 4.8.1 and Buddy theme.
There were 2 issues with that:
- Suddenly I wasn't able to open single activity item. Before this I didn't use it (single activity) much, so I don't know if this issue was from the beginning (the website is still not in production). So I found that this piece of code:
<?php // If activity author does not match displayed user, block access. if ( true === $has_access && bp_displayed_user_id() !== $activity->user_id ) { $has_access = false; }
is always returning $has_access = false, because on the activity page bp_displayed_user_id() is always = 0. I have tried to change my theme to Twenty Seventeen with no success (for bug). So I just commented the lines in bp-activity-screens.php and everything was working again.
- Second issue happened yesterday after installing rtMedia plugin. $has_access became empty after these lines:
<?php $has_access = apply_filters_ref_array( 'bp_activity_permalink_access', array( $has_access, &$activity ) );
I don't really understand the connection between rtMedia plugin and Activity. Not familiar with BP core. If I am disabling the rtMedia plugin - works fine. But I need the plugin, so I fixed it by setting $has_access = true if this line returns it empty. Now it's working again with the plugin.
Change History (4)
#3
in reply to:
↑ 2
@
7 years ago
- Cc inna.zengin@… added
Replying to bhargavbhandari90:
Hi,
Both your parts of the answer is for my part/issue 1, I wasn't able to open the single activity item, because of bp_displayed_user_id() = 0. So, first I have paid attention that links to comment from emails (like "you have new comment to your post/activity") leading to user's (who's clicking on the link) profile with "you do not have access to this activity" error notification. So I was going to side-wide activity page and replying just from there. Or from specific user's activity (from his profile).
But after that I made some changes, removed user's activity from profile by this code in functions.php:
<?php if( !defined( 'BP_DEFAULT_COMPONENT' ) ){ define( 'BP_DEFAULT_COMPONENT', 'profile' ); } function bp_remove_profile_tab_activity(){ bp_core_remove_nav_item('activity'); } add_action( 'bp_setup_nav', 'bp_remove_profile_tab_activity', 900 );
and comments from site-wide activity page by this in entry.php:
<?php if ( bp_activity_can_comment() ) : ?> <?php if ( bp_is_single_activity() ) : ?> <a href="<?php bp_activity_comment_link(); ?>" class="button acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?>"><?php printf( __( 'Comment %s', 'buddypress' ), '<span>' . bp_activity_get_comment_count() . '</span>' ); ?></a> <?php else : ?> <a href="<?php bp_activity_thread_permalink() ?>" class="button acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?>"><?php printf( __( 'Comment %s', 'buddypress' ), '<span>' . bp_activity_get_comment_count() . '</span>' ); ?></a> <?php endif; ?> <?php endif; ?>
And only then I started to check the code for $has_access. It means, that the error for "you do not have access bla-bla" was before I made changes, but I have started to debug the code only after my changes.
Hope, now it's clearer :)
#4
@
7 years ago
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from new to closed
- Version 2.9.0 deleted
Thanks for posting, @udarmo, but can we keep unverified reports in the forums? Bug reports in Trac can be posted if they can be replicated and reproduceable, preferaby on a stock install.
I see that you've already created a thread about this here:
https://buddypress.org/support/topic/buddypress-activity-link-is-broken/
As always to debug, deactivate all your plugins except BuddyPress and remove all your code snippets and see if you can duplicate your issue. If you can't, then it's not a BuddyPress issue.
If you have verified that there is a problem with BuddyPress, then we can reopen this for further investigation.
Hi @udarmo
I checked both of your issues.
Suddenly I wasn't able to open single activity item
-- I am not facing any issue with logged in as well as without logged in and also by logging in by other users.
always returning $has_access = false, because on the activity page bp_displayed_user_id() is always = 0
and$has_access became empty after these lines:
-- I also checked this and getting
true
for$has_access
and got particular user's id forbp_displayed_user_id()
(with logged in as well as without logged in)Can you tell me the steps so that I can replicate these issues.
My versions:
WP: 4.8.1
BP: 2.9.0
rtMedia plugin: 4.4.3
Let me know if I am missing something.