Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to limit activty loop to friends only sitewide with the exception of the admin?


  • 9087877
    Inactive

    I added the below code snippet to my activity-loop.php :

    It limits the activity to my friends only, but does not display mine after I refresh the page. Also when I go to Activity/All Members and Activity/My Friends it displays the exact same thing and only displays my friends activity and not mine. I would like to limit the activity stream of my users to a friend only activity stream but as an administrator I need to see whats going on site wide, so how can I accomplish this? I would really appreciate help on this matter. Thank you!

Viewing 8 replies - 1 through 8 (of 8 total)

  • Boone Gorges
    Keymaster

    @boonebgorges

    There’s a couple different things happening here.

    First, because you’re hardcoding the additional parameters directly in the template, they apply to everywhere in your theme where you show activity. You might consider either switching it to a filter of `bp_ajax_querystring`, so that you can put some logic into the function (eg, `if ( bp_is_current_action( ‘friends’ ) ) // do this; else // do this;`), or doing that logic right in the template:

    `$params = ”;
    if ( ! is_super_admin() ) {
    $params .= ‘&scope=friends’;
    }
    ?>
    `


    9087877
    Inactive

    @boonebgorges
    Ok here is what I put in the template:
    ` $params = ”;
    if ( ! is_super_admin() ) {
    $params .= ‘&scope=friends&per_page=5’;
    }
    ?>

    `

    Works almost perfect except for when I attempted passing the second parameter &per_page=5.
    On normal users the above code does limit site wide activity to a friends only activity stream and loads only 5 items which is what I want. When I am on the admin account it does show me all activities which is perfect, but for some reason the second parameter &per_page=5 reverts back to displaying 20 activity items. I would still like to also limit the admin to 5 activity items just to help the activity load a little faster. Thanks a lot Boone for what you do, and your help so far!


    9087877
    Inactive

    @boonebgorges
    I guess what I am asking is did I pass the 2nd parameter of &per_page=5 wrong? I just want the same behavior with the exception that I want all users including admin to only get 5 items in activity with the load more option below the 5 loaded activities. If I am missing something I would appreciate the help.
    I really think this is an important thread, with the impending release of BP 1.6 it would help for developing child themes for BP with more control over activity privacy in conjunction with the profile privacy visibility features in BP 1.6. Thanks Boone!


    shanebp
    Moderator

    @shanebp

    `if ( is_super_admin() )
    $params .= ‘&per_page=5’;
    else
    $params .= ‘&scope=friends&per_page=5’;
    `


    9087877
    Inactive

    I am trying to pass 2 parameters to the user on the if/else statement as the below code shows. The main issue is the else. It loads only 5 items per page as it should, but the &scope=friends is not filtering the activity to show only friends activity for non-admins. Please tell me what I am doing wrong here! Thank you.
    `<?php
    $params = ”;
    if ( ! is_admin() )
    $params .= ‘&per_page=5’;
    else
    $params .= ‘&scope=friends&per_page=5’;

    ?>

    `


    shanebp
    Moderator

    @shanebp

    Simple, and already answered – flip the if/else actions or remove the false operator like so

    `if ( is_super_admin() )
    $params .= ‘&per_page=5’;
    else
    $params .= ‘&scope=friends&per_page=5’;`

    If this is still confusing – read up on if/else and what the ! operator does – it means false.


    9087877
    Inactive

    Does anyone know how I can do this? It doesn’t seem like it should be that hard to do. Maybe I am missing something in the syntax or something. Please help. Thank you!


    9087877
    Inactive

    That does limit activity to friends only and limits items loaded to 5 but it doesn’t show show your own activity updates after you refresh the page Shane. The users want to see their own activity updates as well, so the issue isn’t fixed yet. Any help would be appreciated!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to limit activty loop to friends only sitewide with the exception of the admin?’ is closed to new replies.
Skip to toolbar