This topic has 20 replies, 11 voices, and was last updated 10 years by gurpreetsaggu.

  • Author
  • #1167
     angelgallegos
    Participant

    Hi,

    Do you know how can we hide Admin from member loop (most recent, new members and most popular) on homepage and in search results?

    Also, how can we prevent users to see Admin profile?

    Thanks.

    #1173
     SQadmin
    Keymaster

    Hi,
    To hide Admin profile you could add this snippet to your sweetdate-child/functions.php:

    COPY CODE
    
    /* Hide admin */
    add_action('bp_init', 'kleo_private_admin');
    function kleo_private_admin(){
        global $bp;
        if(is_super_admin())
        {
            remove_action("wp_head","bp_core_record_activity"); //id SM is on, remove the record activity hook
            //then remove the last activity, if present
            delete_user_meta($bp->loggedin_user->id, 'last_activity');
        }
    }
    
    add_action('bp_ajax_querystring','kleo_exclude_users',20,2);
    function kleo_exclude_users($qs=false,$object=false)
    {
        //list of users to exclude
    
        $excluded_user='1';//comma separated ids of users whom you want to exclude
    
        if($object!='members')//hide for members only
        return $qs;
    
        $args=wp_parse_args($qs);
    
        //check if we are listing friends?, do not exclude in this case
        if(!empty($args['user_id']))
        return $qs;
    
        if(!empty($args['exclude']))
        $args['exclude']=$args['exclude'].','.$excluded_user;
        else
        $args['exclude']=$excluded_user;
    
        $qs=build_query($args);
    
        return $qs;
    }
    
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #1175
     angelgallegos
    Participant

    Hi,

    It seems to work to hide Admin from that members loops except popular members, where it is still appearing.

    Also, it appears on groups, because Admin create groups… It could be solved if normal users when trying to view admin profile are redirected to their profiles, how can I do that?

    Thanks again.

    #1195
     SQadmin
    Keymaster

    Hi,
    This shows a 404 error on the admin page:

    COPY CODE
    
    // Hide admin profile pages
    add_action( 'wp', 'hide_profile_template', 1 );
    function hide_profile_template() {
    global $bp; 
        if(bp_is_profile AND $bp->displayed_user->id == 1 AND $bp->loggedin_user->id != 1) :
            global $wp_query;
            $wp_query->set_404();
            status_header(404);
            include(locate_template('404.php'));
            exit;
        endif;
    }
    

    For groups just create the groups with another user.
    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #1209
     angelgallegos
    Participant

    Hi,

    I get an unknown error and I have to restore my sweetchild theme functions.php when I try to add the second code (Admin 404).

    Do you know why?

    Thanks again, awesome work!

    #1211
     SQadmin
    Keymaster

    Hi,
    I have modified the above file. The editor transformed some characters.
    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #1215
     angelgallegos
    Participant

    Hey!

    It works now! Thanks! 😉

    #3924
     notime
    Participant

    I added the administration code with perfect results, did just what I wanted, I was wondering if this code can be adapted to hide users/members without a paid membership? Which is a good feature for sites that have paid memberships for showing profiles.

    #4303
     mpaxton
    Participant

    What would keep the above code from working? I have adapted it to the sweetdate_child theme functions.php, which is all the code that is in that file, other than the standard comments. After doing so, the administrators are still showing in the general member search.

    #4354
     SQadmin
    Keymaster

    Hi,
    That code hides only the admin with user ID = 1 by default
    You need to modify this to match your ids:
    $excluded_user=’1′;//comma separated ids of users whom you want to exclude

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #5771
     apine0322
    Participant

    How can I remove the admin account from the total member count? If I have 2 members (admin and a free member) it shows 2 members, even though the admin profile is blocked. How can I remove the admin profile so it only says 1 member?

    #5846
     SQadmin
    Keymaster

    Hi,
    That is a default Buddypress function: bp_total_member_count() that gets all members

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #6189
     Bottosso
    Participant

    Hi

    I put the code below in my sweetdate-child functions, the problem was solved in members page and “Latest registered members” but the admin user still appear in “Top Members” Please find below the screenshot.

    http://cl.ly/image/1Y0S0o1F1C1P

    Many Thanks

    #6279
     SQadmin
    Keymaster

    Hi, We checked and the admin doesn’t appear. Make sure you login as that admin user and have the codes added to your sweetdate-child/functions.php

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #8283
     rogerbose
    Participant

    The functions.php file in the sweetdate-child/functions.php, does it need to be blank, or a copy of the functions.php from the sweetdate/ folder?

    Also I am seeing the admin photo and profile in the widget that shows (Newest, Active, Popular). I see the photo and profile in the popular, but not in the active.

    #8346
     Abe
    Keymaster

    Hi, the functions.php should be blank, just as you have it when you install the child theme. That widget is buddypress default. Try searching a solution on buddypress forums

    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #11765

    This fix does not hide the admin user from the “Quick profile navigation” for me.

    #22885
     collandi
    Participant

    It works fine with the Members list – but not in the widgets:
    – who is online
    and
    – Recently active members
    How can I hide the admin from these widgets?

    #23057
     Abe
    Keymaster

    Those widgets come from Buddypress and we can’t edit them. Try to find a solution on Buddypress forums

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #37875
     gurpreetsaggu
    Participant
    This reply has been set as private.
    #37878
     gurpreetsaggu
    Participant

    Please ignore the previous comment. its working like charm 🙂

Viewing 21 posts - 1 through 21 (of 21 total)

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?