Skip to:
Content
Pages
Categories
Search
Top
Bottom

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 !

Viewing 4 replies - 1 through 4 (of 4 total)
  • Anyone ?


    Virtuali
    Participant

    @gunju2221

    Put it into your bp-custom.php, and there ya go!

    Although it hasn’t been updated to work in the latest versions on buddypress, so I am not guaranteeing that it will work.


    TimCarey
    Participant

    @timcarey

    Would you know how to do this for the group-header? I would like the group-header too be nonexistent during a certain condition. But I like to do this in my plug in.

    @gunju2221 yep, did that, but all it does is add “To view this activity – please log in first. You can also create an account.” after showing the activty, it does not hide it for unlogged users. Using 1.2.7 with 3.0.5

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Hiding activity content for non-logged users’ is closed to new replies.
Skip to toolbar