Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide activities of the administrator


  • sokolum
    Participant

    @sokolum

    Googled around, an older examples won’t work with the current version of BuddyPress 2.4.3. How to make sure that the activities of the Administrator isn’t recorded or not shown, sitewide / plugins / etc….

    Prefer to add this in: bp-custom.php

    Thank yo in advance.

    Code what i had found:

    
    <?php
    // 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’);
    }
    ?>
    

    Here’s another code, this removes the activity of the currently logged in user itself from the page, this still works:
    But obviously it wont hide the administrator’s activity in the users perspective!

    
    <?php
    //filter on pre_user_query
    add_action( 'pre_user_query', 'devb_exclude_loggedin_user', 201 );
    
    function devb_exclude_loggedin_user( $query ) {
        //don't modify the query if the user is not logged in
        if ( !is_user_logged_in() )
            return;
        //do not hide users inside the admin
        if ( is_admin() && !defined('DOING_AJAX') )
            return;
        $qv = $query->query_vars;
    
        global $wpdb;
        //hide
        $query->query_where .= $wpdb->prepare(" AND {$wpdb->users}.ID !=%d ", get_current_user_id());
    }
    ?>
    
Viewing 2 replies - 1 through 2 (of 2 total)

  • blogook
    Participant

    @jgob

    Hi,

    You can use the code from buddydev. You just have to change one single thing

    <?php
    //filter on pre_user_query
    add_action( 'pre_user_query', 'devb_exclude_loggedin_user', 201 );
    
    function devb_exclude_loggedin_user( $query ) {
        // code below we do not need
        //don't modify the query if the user is not logged in
        // if ( !is_user_logged_in() )
        //    return;
    
        //do not hide users inside the admin
        if ( is_admin() && !defined('DOING_AJAX') )
            return;
        $qv = $query->query_vars;
    
        global $wpdb;
        //hide little change at the end of the query.I changed it to user_id : 1
        // but userID can be anything. I chose 1 because that is my admin user_id
        $query->query_where .= $wpdb->prepare(" AND {$wpdb->users}.ID !=%d ", 1 );
    }
    ?>

    @mcuk
    Participant

    @mcuk

    This might help (change ID from 1 in the appropriate places to the ID of your administrator(s). ID’s found in your database ):

    https://buddypress.org/support/topic/hide-all-admins-from-all-buddypress-activities/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide activities of the administrator’ is closed to new replies.
Skip to toolbar