Hiding activity content for non-logged users
-
Hi there,
I realized that instead of blocking the whole activity page to non-logged users I could just hide the activity content and leave the activity header intact
How can I achieve this ? So far, the only thing I found is @nuprn1 code here: http://etivite.com/groups/buddypress/forum/topic/quick-tip-hide-activity-updates-andor-replies-by-types-for-non-logged-visitors-in-users/`//block activity stream parent comment and children replies
function my_bp_get_activity_content_body( $content, $activity ) {
global $activities_template, $bp;if ( is_user_logged_in() )
return $content;if ( !my_bp_get_activity_content_body_hide_check($activities_template->activity->type) )
return $content;$activity->children = null;
$content .= sprintf( __( ‘To view this activity – please log in first.’, ‘buddypress’ ), $bp->root_domain . ‘/wp-login.php?redirect_to=’ . urlencode( bp_activity_get_permalink( $activities_template->activity->id ) ) );
if ( bp_get_signup_allowed() )
$content .= ‘‘. sprintf( __( ‘ You can also create an account.’, ‘buddypress’ ), site_url( BP_REGISTER_SLUG . ‘/’ ) ) .’‘;return $content;
}
add_filter(‘bp_get_activity_content_body’, ‘my_bp_get_activity_content_body’, 1, 2);//any type here to define
function my_bp_get_activity_content_body_hide_check( $type ) {
return in_array( $type, apply_filters( ‘bp_activity_block_denied_activity_types’, array( ‘activity_update’ ) ) );
}`
But I do not know how to tailor it to my needs…any help is appreciated !
- The topic ‘Hiding activity content for non-logged users’ is closed to new replies.