Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Tips] Buddypress Hiding Admin/specific user member & activity


  • 83 Oranges
    Participant

    @umagokhale

    Here are some useful #Buddypress tricks to hide Admin/specific user member & activity. The codes can be added to bp-custom.php, a file that you can create and upload to your ’Plugins’ folder.

    EDIT – link removed as it does not lead to any tip page anymore.
    mercime

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

  • danbpfr
    Participant

    @chouf1

    hi @umagokhale,

    thank you for this sharing ! 😉


    83 Oranges
    Participant

    @umagokhale

    You’re welcome @Chouf1! For regular updates and to network with others having similar web & design interests, do join our exclusive social network here: 83oranges.com/connect

    Cheers!

    How about adding some of these tips to the BP codex perhaps?

     

    If you are going to leave links to your site please check those links are correct, also I would advise that you turn off PHP error reporting on a production server it’s really not very smart to announce to the world your server paths.


    danbpfr
    Participant

    @chouf1

    Thank you for your invite @umagokhale, but i’m already doing that on the french BP support since 4 years
    http://bp-fr.net/groupes/comment-faire-pour/forum/


    @hnla
    ,

    i added a page with tricks to the Customize Page a few weeks ago. Thinking like you it could be a good help to have such common tricks avaible from the Codex.
    The whole Codex staff, included JJJ, fall over my head ! And the page was deleted  a few hours later.
    Explanation was: the codex wiki pages are difficult to organize, code snippets aren’t always valuable over versions and by this, aren’t usage reference. The BP Codex is a reference, not a place to publish how to use it in concrete case, nor to learn how to customize it. Codex is codex and forum is forum. No comment. 😉

    The only thing possible (allowed) to add on Codex is a link to a tread containing the trick. But not the trick directly. Why made simple when complicated can be done ?

    Dura lex, code ex. 😀

    @chouf1 Ah right wasn’t aware of that prohibition on adding tips and code snippets, last time I looked there were a few. As long as they follow some form of best practise they ought to be ok.

    On this basis “nor to learn how to customize it.” then to codex BP loops will need to be removed as they are technically customizations.


    Ben Hansen
    Participant

    @ubernaut

    Seems like there should be an official place for such things and if not the codex then where?

    Definitely a useful tip @umagokhale an issue that comes up quite a bit. Seems a bit odd your links are redirecting to customwebdesignseo.com even though you have already rebranded to 83 Oranges on the site and you obviously own both domains, but it is a nice looking site.


    Suraj
    Participant

    @surajverma

    @umagokhale: hello, was wondering for last few days about the same, till now no luck. The code you provided is not working on my page. The page is not live yet so can not provide the link.


    Ben Hansen
    Participant

    @ubernaut

    something must be off on your code cause the code definitely works.


    Suraj
    Participant

    @surajverma

    @ubernaut: Thank you very much for your response, What information do I need to provide you to check what is the issue ?

    I made a new file with the name bp-custom.php with this code

    <?php
    // Code for: Don’t record activity by the site admins or show them as recently active
    function my_admin_stealth_mode(){
    if ( is_site_admin() ) {
    global $bp;
    remove_action(’wp_head’,’bp_core_record_activity’);
    delete_user_meta($bp->loggedin_user->id, ’last_activity’);
    }
    }
    add_action(’init’,’my_admin_stealth_mode’);
    //Code for: Don’t record activity for a user or show them as recently active
    function my_user_stealth_mode(){
    $current_user = wp_get_current_user();
    if(is_user_logged_in()) {
    if(’admin’ == $current_user->user_login) {
    remove_action(’wp_head’,’bp_core_record_activity’);
    delete_user_meta($current_user->ID, ’last_activity’);
    }
    }
    }
    add_action(’init’,’my_user_stealth_mode’);
    ?>

    and placed it in plugin folder of the wp installation. It is not giving any error but admin activity is showing in the activity. One more thing I need to know, whether it will remove previous activity as well or not ? and do I need to change the account name to admin ?
    Thanks a ton in advance.


    Ben Hansen
    Participant

    @ubernaut

    i’m not using that one i’m using this one:

    <?php
    
    //hide superadmin
    
    add_action("plugins_loaded","bpdev_init_sm_mode");
    function bpdev_init_sm_mode(){
    if(is_site_admin())
    remove_action("wp_head","bp_core_record_activity"); //id SM is on, remove the record activity hook
    }
    
    ?>

    Suraj
    Participant

    @surajverma

    @ubernaut: Thank you again for your prompt response, I tried this earlier but it this one is also not working, if I am not wrong then it must be the code provided on Brajesh Singh’s blog, buddydev. I am using Frisco Child theme for Buddypress, I tried placing both the codes in function-custom.php and as mentioned in plugins folder as well,but didn’t succeeded. :-(. Please help, what to do. I need to make the website live.


    Ben Hansen
    Participant

    @ubernaut

    the file is supposed to be called bp-custom


    Suraj
    Participant

    @surajverma

    @ubernaut: yes, I did the same with the said parameters all correct, as I am using frisco theme then I can do the same thing by putting the code in function-custom.php. First I tried the bp-custom.php (placed in plugin folder) option , that didn’t worked out for me, so I tried the later, but that didn’t worked either. 🙁


    Ben Hansen
    Participant

    @ubernaut

    not sure what to tell you sorry not very strong with the php


    Suraj
    Participant

    @surajverma

    @ubernaut: No problem, thank you very much. At least you tried to help. 🙂


    boydspace
    Participant

    @boydspace

    Can anyone tell me how to apply any of the codes above to specific user roles?


    Ben Hansen
    Participant

    @ubernaut

    there’s probably a term you can swap for is_site_admin() but i don’t know what it is, sorry.


    geoffreysf
    Participant

    @geoffreysf

    Putting this in the functions or bp-custom.php files did not work.

    I finally managed to get the admin and any other user excluded from the members directory by modifying the bp_had_members query that was already in my members-loop.php file.

    <?php if ( bp_has_members( bp_ajax_querystring( ‘members’ ).’&exclude=1,3,25′ . ‘&type=alphabetical&per_page=30’ ) ) : ?> <!– &exclude= user_ids of the people you want to exclude –>

    By adding just this, it also removed the users from the total members count.

    Note: I do not use friends or activity feeds on my site, so I have no idea if it hides from them, but I suppose it wouldn’t.

    I have been looking high and low for the answer to this with my limited PHP knowledge… and wanted to share it back so other people could learn from it too.

    And credit where it is due, this post led me to the answer.
    https://buddypress.org/support/topic/member-parameters-not-working-with-bp_ajax_querystring/


    webcore
    Participant

    @webcore

    this code is outdated and ineffecitve as of buddypress 2.0.2.


    danbp
    Moderator

    @danbp

    Since 2.0 you can use bp_parse_args to filter templates

    This topic is outdated and accordingly to what mercime mentionned in the first post, it is also the reason why this tread is now closed.

Viewing 20 replies - 1 through 20 (of 20 total)
  • The topic ‘[Tips] Buddypress Hiding Admin/specific user member & activity’ is closed to new replies.
Skip to toolbar