Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'Hide Admin'

Viewing 25 results - 226 through 250 (of 634 total)
  • Author
    Search Results
  • #235132
    whoaloic
    Participant

    Hey,
    I’ve found how to hide admin member in member menu but not in group menu in member tabs.
    More specifically: site admin (user ID 1) is admin of groups A, B, C.
    I would love the admin be hidden in member tab of groups A and B, but still be visible in member tab of group C.

    #235021
    danbp
    Participant

    Hello,

    please try to search in topics if a similar question wasn’t ask in the past.
    hide+admin+in+admin

    A possible solution here.

    #233941
    format19
    Participant

    Hi Henry,

    Thanks for that, yes I did realize that I have been all over the codex as you can imagine but figuring out exactly what code I needed was getting me a bit bogged down.

    I have managed to achieve it a different way.
    I used USER ROLE EDITOR to create a new role again called Editor Plus but this time copied the settings from Administrator then took away privileges
    Finally I used Adminimize to hide additional menu items.

    This has worked perfect, Now my 2 site owners are set as Editor Plus and Moderators they can see all users data including Extended info but cant see any of the stuff that can actually break the site šŸ™‚

    Thanks again
    M

    #233512
    Henry Wright
    Moderator

    Hi @screampuff

    You can make that link private by doing something like this:

    function screampuff_hide_achi() {
        // Bail if the current user is the displayed user.
        if ( bp_loggedin_user_id() == bp_displayed_user_id() )
            return;
    
        // Bail if the current user is an admin.
        if ( current_user_can( 'manage_options' ) )
            return;
    
        // Bail if not the achievements page.
        if ( bp_current_action() != 'achievements' )
            return;
    
        // Redirect.
        wp_redirect( home_url() );
        exit;
    }
    add_action( 'template_redirect', 'screampuff_hide_achi' );

    Please note I haven’t tested. Also, I’m assuming the current action is ‘achievements’. It may be something else in which case the function will need a minor tweak.

    #233342
    David13_13
    Participant

    Hello

    I only want to hide it because it shows my username to access admin panel in WordPress too… A hacker only would need to hack my pass.

    It’s not possible to hide it in all the website?

    Thanks

    #233226
    danbp
    Participant

    hi @david13_13,

    be more specific please.

    @username
    is used all over the site, and for anybody.
    Even if you hide only YOURS on a specific part, like your profile header, users will see your username on activities, or when they mention you.

    Do you need this to aply only to you, as site admin, on your profile page ?
    Or elsewhere too ?

    #233041
    Garrett Hyder
    Participant

    Update – Found an issue with my code when you go to the second page of the Members Groups list it reverts to showing hidden, etc. This is due to the call being done with AJAX which is considered an admin so !is_admin is false. To correct this I’ve updated the if statement to check if DOING_AJAX:

    // Buddypress Filter Hidden Groups from Groups Loop
    function filter_hidden_groups_sql($sql) {
    	if (!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)){
            $sql_parts = explode('WHERE', $sql);
            $new_sql = $sql_parts[0] . "WHERE g.status != 'hidden' AND" . $sql_parts[1];
    	    return $new_sql;
    	} else {
    		return $sql;
    	}
    }

    Basically this allows the backend admin to list all groups but the front end hides the hidden ones.

    Cheers

    screampuff
    Participant

    Thanks for the reply. I made some changes to the code before reading and was able to accomplish removing the tab from buddypress profiles with this:

    function hide_achievements_from_users() {
    global $bp;
    if ((bp_loggedin_user_id() == bp_displayed_user_id()) || (current_user_can('administrator'))){
    return;
    }
    bp_core_remove_nav_item('achievements');
    }
    add_action( 'bp_setup_nav', 'hide_achievements_from_users', 99 );

    However I’m stuck on how to 404 the pages if they manually type out the URL

    In your code I see:

        // I guess we should 404 this page because this member isn't an admin or the displayed member.
        $wp_query->set_404();
        status_header( 404 );
        nocache_headers();

    How do I get this to apply only when it is http://mysite.com/members/<username>/achievements?

    #232706
    youmin
    Participant

    i have a question for r-a-y, is it not possible to make it one time select able (for users), i mean locking down after selecting once or twice.
    but admin can change it on user request ?

    or making it available on registration form only ?

    i also saw the ticket above mentioned but its just hiding the box from user, i dont think its a perfect solution. i will be good to hide after selecting a member type by a user .

    Henry Wright
    Moderator

    Hi @screampuff

    You could try the following function which will stop unwanted users from viewing the page directly if they tried typing the URL:

    function my_hide_achievements_page() {
        $role = xprofile_get_field_data( 'Membership' );
    
        if ( ( $role != 'Administrator' ) || ( bp_current_user_id() == bp_displayed_user_id() ) )
            return;
    
        // I guess we should 404 this page because this member isn't an admin or the displayed member.
        $wp_query->set_404();
        status_header( 404 );
        nocache_headers();
    }
    add_action( 'init', 'my_hide_achievements_page' );
    #231785
    Kir 2012
    Participant

    Hi there, I’m sorry to jump in on your post, I would like to know how to do this too – kind of.
    OP,I think this may be of some help to you.

    Admin, it may just be me being slow today, but I can’t see how to start a new thread or help request from my dash, could you pop a link here for me? Sorry about that! šŸ™

    Anyone, I would like to know how to hide (not remove) only the top nav menu, with ‘profile, activity, messages, friends’ etc. I have this menu elsewhere. I want to remove it from all other places. But I need to keep the subnav links visible.

    I know how to -remove- an item nav/subnav – but want to -hide- top links without removing the actual function of the url in order that I can still link to it from my own menu.

    I can edit the css in buddypress.css, I’ve tried a few things but nothing works so far, like.

    #buddypress div.item-list-tabs {display:none};

    I’ve also tried finding the link to the menu in the home or message-header.php in buddypress/bp-templates/bp-legacy/buddypress/members/single to amend it there.

    If anyone could help I’d be so grateful, and sorry OP for riding your post, hope the link helped you. Admin if you could post me a link to start a new thread that would be great šŸ™‚ Thank you

    #231282
    shanebp
    Moderator

    This will hide fields on the profile edit page and on the register page.
    You need to add the field IDs.
    Put the function in bp-custom.php.

    function oazar_hide_profile_fields( $retval ) {
    	
    	if( is_super_admin () )
    		return $retval;
    
    	if(  bp_is_profile_edit() || bp_is_register_page() )
    		$retval['exclude_fields'] = '3';	//field ID's separated by comma
    
    	return $retval;
    
    }
    add_filter( 'bp_after_has_profile_parse_args', 'oazar_hide_profile_fields' );
    #231214
    shayne
    Participant

    I figured it out. For some reason WordPress decided it would be a good idea to hide custom menus added to the toolbar(when did they change the name from admin bar?) when viewing it on mobile devices.

    If you browse through the WordPress directory you will find the css for the toolbar in wp-includes\css\admin-bar.css.

    This line hides everything but the default items from the toolbar.

    	/* Show only default top level items */
    	#wp-toolbar > ul > li {
        		display: none;
    	}

    By changing “display: none” to “display: block”. That fixed the problem i was having.

    So hopefully that information is useful to someone.

    Oh and one more thing. If you need to modify the toolbars css don’t do it there. You shouldn’t modify WordPress’s core files. Instead you should copy that css to your themes style sheet.

    #230995
    Mathieu Viet
    Moderator

    Hi @danbp asked me about this.. So here’s a way to hide the tabs

    
    function turker_remove_group_admin_tab() {
    	if ( ! bp_is_group() || ! ( bp_is_current_action( 'admin' ) && bp_action_variable( 0 ) ) || is_super_admin() ) {
    		return;
    	}
    
    	// Add the admin subnav slug you want to hide in the
    	// following array
    	$hide_tabs = array(
    		'group-avatar' => 1,
    		'delete-group' => 1,
    	);
    
    	$parent_nav_slug = bp_get_current_group_slug() . '_manage';
    
    	// Remove the nav items
    	foreach ( array_keys( $hide_tabs ) as $tab ) {
    		bp_core_remove_subnav_item( $parent_nav_slug, $tab );
    	}
    
    	// You may want to be sure the user can't access
    	if ( ! empty( $hide_tabs[ bp_action_variable( 0 ) ] ) ) {
    		bp_core_add_message( 'Sorry buddy, but this part is restricted to super admins!', 'error' );
    		bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) );
    	}
    }
    add_action( 'bp_actions', 'turker_remove_group_admin_tab', 9 );
    #230896
    webplayer
    Participant

    I am not a coder, but I’m looking for a snippet that can do this:

    Add Function: Change Admin Bar Login and Register Links
    
    if user is logged out
    
    Remove WordPress/buddypress admin bar Login and Register links
    
    Add New Login and Register Links
    
    New Login Link: <a data-reveal-id="tmpl_reg_login_container" href="javascript:void(0);" onclick="tmpl_login_frm();">New Login Link</a>
    
    New Register Link: <a data-reveal-id="tmpl_reg_login_container" href="javascript:void(0);" onclick="tmpl_registretion_frm();">New Register Link</a>
    
    if user is logged in don't do any of the above (i.e.) show their buddypress username and hide register links, etc...
    

    Does anyone know how to make this happen in code that I can drop into functions.php or bp-custom.php

    #230718
    danbp
    Participant

    Hi @amic58, @tecca

    When BP is installed and xProfile is activated, the original WP profile settings are not accessible to user.

    The WP register process use only username, password and email and BuddyPress add by default a Name field as base for other extended profile fields.

    In short this means that username and name fields can contain a same information(a name, a pseudonym, a first or/and a last name). The plugin you mention is best for a WP install where user had choosen first/last name as output on post, comments, etc Once BP is activated, this became a little different.

    Now to the initial question.
    The CSS trick is a very inelegant solution as it lets everybody knowing how BP works to surround this invisibility. You’re also loosing any flexibility if you want to show some fields privately for example.

    You can do this properly with a little snippet, as explained here:

    Using bp_parse_args() to filter BuddyPress template loops

    Here’s an example which let you hide fields or fiels group to members, but not to site admin

    function bpfr_hide_profile_field_group( $retval ) {
    	if ( bp_is_active( 'xprofile' ) ) :	
    	
    	// hide profile group/field to all except admin	
    	if ( !is_super_admin() ) {		
    		//exlude fields, separated by comma
    		$retval['exclude_fields'] = '1';  
    		//exlude groups, separated by comma
    		$retval['exclude_groups'] = '1'; 			
    	} 
    	return $retval;		
    	
    	endif;
    }
    add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_field_group' );

    Add it to bp-custom.php or your child-theme functions.php

    Of course you can also choose to show a field or group, but remove the possibility for the user to edit it later. Simply add more conditionnal to the function.

    Here another example:

    function bpfr_hide_profile_edit( $retval ) {	
    	// remove field from edit tab
    	if(  bp_is_user_profile_edit() ) {		
    		$retval['exclude_fields'] = '54'; // ID's separated by comma
    	}	
    	// allow field on register page
    	if ( bp_is_register_page() ) {
    		$retval['include_fields'] = '54'; // ID's separated by comma
    		}		
    	
    	// hide the field on profile view tab
    	if ( $data = bp_get_profile_field_data( 'field=54' ) ) : 
    		$retval['exclude_fields'] = '54'; // ID's separated by comma	
    	endif;	
    	
    	return $retval;	
    }
    add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_edit' );

    Hope to be clear.

    #229193
    shanebp
    Moderator

    Assuming the user_id for the admin is 1, try this:

    function infok_exclude_users($qs=false,$object=false){
        //list of users to exclude
         $excluded_users = '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 searching for friends list etc?, do not exclude in this case
        if(!empty($args['user_id']))
            return $qs;
        
        if(!empty($args['exclude']))
            $args['exclude']=$args['exclude'].','.$excluded_users;
        else 
            $args['exclude']=$excluded_users;
          
        $qs=build_query($args);
         
       return $qs;   
    }
    add_action('bp_ajax_querystring','infok_exclude_users',20,2);
    #227724
    iburnthings
    Participant

    https://buddypress.org/support/topic/hide-profiles-of-a-specific-role-not-admin/

    I created a new thread. Sorry to hijack/resurrect this thread.

    #227719
    shanebp
    Moderator

    There are a few issues with that solution.
    1. ‘1’ can’t view their own profile
    2. What if there are multiple admins

    Suggestion:

    function hide_admin_profiles() {
    
        // Bail if this is not a profile.
        if ( ! bp_is_user_profile() )
            return;
    
        if ( ! is_super_admin() ) {
             if ( is_super_admin( bp_displayed_user_id() ) ) {
                 wp_redirect( home_url() );
                 exit;
             }
        }
    }
    add_action( 'init', 'hide_admin_profiles' );
    
    #227718
    Henry Wright
    Moderator

    Hi @dreamh11,

    Try adding this to your theme’s functions.php file:

    function hide_admin_profile() {
    
        // Bail if this is not a profile.
        if ( ! bp_is_user_profile() )
            return;
    
        // This assumes the member ID of the admin user is 1.
        if ( 1 == bp_displayed_user_id() ) {
            // We're trying to view the admin's profile so redirect to the homepage.
            wp_redirect( home_url() );
            exit;
        }
    }
    add_action( 'init', 'hide_admin_profile' );
    danbp
    Participant

    Please use the code button to insert code in a topic. Thank you !

    Give this a try

    // deny access to admins profile. User is redirected to the homepage
    
    function bpfr_hide_admins_profile() {
    	global $bp; 
    	if(bp_is_profile && $bp->displayed_user->id == 1 && $bp->loggedin_user->id != 1) :
    	wp_redirect( home_url() );
    	exit;
    	endif;
    }
    add_action( 'wp', 'bpfr_hide_admins_profile', 1 );
    
    // Remove admin from the member directory
    
    function bpdev_exclude_users($qs=false,$object=false){
    	
    	$excluded_user='1'; // Id's to remove, separated by comma
    	
    	if($object != 'members' && $object != 'friends')// hide admin to members & friends 
    	return $qs;
    	
    	$args=wp_parse_args($qs);
    	
    	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;
    	
    }
    add_action('bp_ajax_querystring','bpdev_exclude_users',20,2);
    
    // once admin is removed, we must recount the members !
    
    function bpfr_hide_get_total_filter($count){
    	return $count-1;
    }
    add_filter('bp_get_total_member_count','bpfr_hide_get_total_filter');
    
    // hide admin's activities from all activity feeds
    
    function bpfr_hide_admin_activity( $a, $activities ) {	
    	
    	// ... but allow admin to see his activities!
    	if ( is_site_admin() )	
    	return $activities;	
    	
    	foreach ( $activities->activities as $key => $activity ) {	
    		// ID's to exclude, separated by commas. ID 1 is always the superadmin
    		if ( $activity->user_id == 1  ) {			
    			
    			unset( $activities->activities[$key] );			
    			
    			$activities->activity_count = $activities->activity_count-1;			
    			$activities->total_activity_count = $activities->total_activity_count-1;			
    			$activities->pag_num = $activities->pag_num -1;				
    		}		
    	}		
    	// Renumber the array keys to account for missing items 	
    	$activities_new = array_values( $activities->activities );		
    	$activities->activities = $activities_new;	
    	
    	return $activities;
    	
    }
    add_action( 'bp_has_activities', 'bpfr_hide_admin_activity', 10, 2 );
    #218765
    danbp
    Participant

    hi @ahd904,

    behind your tech question, two things need some clarification at least.

    First:

    I just want to hide some of the group creation steps as these might make the users think too complicated to join the community.

    Register process doesn’t include group creation, nore joigning a group, so i guess you are thinking about a problem that doesn’t exist at this stage.

    If you allow your users to create groups, they have to follow the 3 creation steps, because it is intended so in BuddyPress. Thinking that this might be to complicated, implies that you think that your users are not able to do this. Mabe you’re right, but maybe not. Anyway in this case, simply deactivate group creation for users and create users groups yourself.
    Assuming that you don’t think it’s too complicated for the user to click on “join group” ! šŸ™„

    As @bphelp said with reason, what your question implies needs some extra coding and much more as a simple snippet. You can do many things with BuddyPress, but not everithing or anything. šŸ˜‰

    Second:
    Core simplification is a hard work (see Trac), so don’t expect that your goal could be reached easily, as BP will never be a “one click” tool. IMO this plugin is already very easy to use as is.

    That said, you could imagine your project differently and perhaps apply another strategy.
    For example, the ability for users to join automatically a group at registration. 2 plugins can do that actually.

    • This one allows a new BuddyPress user to select groups to join during the registration process. You create the group, user choose his group.
    • This one create a new Group when a new user sign up. But what will happen when you have 50 registration by day, spammers included ?

    In both case, pros and cons have to be considered.

    if you love the snippets and sweat on your site, here are two other options.

    #201151
    1a-spielwiese
    Participant

    Follow-up:

    7th:

    Capability Manager Enhanced to define custom user roles, if you’re not satisfied with the default wordpress roles (subscriber, contributor,…).
    The first step is to create your user roles

    https://buddypress.org/support/topic/resolved-different-profile-types-and-different-user-roles/

    As ready implied there: I did this – and it works so far.

    8th:

    Create a xprofile field (selectbox) with the title ā€œUser Roleā€ and name the options ā€œBand Roleā€ and ā€œFan Roleā€ – in my case. You can call them whatever you want. Place this field in the ā€œbaseā€ profile group, otherwise it won’t be shown during registration. Also make the field ā€œrequiredā€. In my case the user can’t decide, if the visibility of the field can be changed.

    I did it already, when I installed and activated ‘BP Profile Search’-plugin – and it works.

    However, to choosed a dropdown menu and the categories ‘team’ and ‘fan’.

    9th:

    I modified:

    ?php
    function custom_bp_core_signup_user($user_id) {
        $user_role = strtolower(xprofile_get_field_data('User Role', $user_id));
        switch($user_role) {
            case "Band Role":
                $new_role = 'band';
                break;
            case "Fan Role":
                $new_role = 'fan';
                break;
        }
        wp_update_user(array(
            'ID' => $user_id,
            'role' => $new_role
        ));
    }
    add_action( 'bp_core_signup_user', 'custom_bp_core_signup_user', 10, 1);

    into:

    function custom_bp_core_signup_user($user_id) {
        $user_role = strtolower(xprofile_get_field_data('Mitglieder-Kategorie (Team oder Fan?)', $user_id));
        switch($user_role) {
            case "Team":
                $new_role = team';
                break;
            case "Fan":
                $new_role = 'fan';
                break;
        }
        wp_update_user(array(
            'ID' => $user_id,
            'role' => $new_role
        ));
    }
    add_action( 'bp_core_signup_user', 'custom_bp_core_signup_user', 10, 1);

    (I omitted <?php, because I created not a new bp-costum.php, rather inserted the code into my yet existing bp-costum.php. I inserted the modified code above the line ?>.)

    I did not understand, which effect this insertion should have – but, however, – as far as I see – it causes no harm.

    Did anyone understood, for which purpose the above mentioned code is?

    10th:

    I inserted as well:

    //hide the user role select field in edit-screen to prevent changes after registration
    add_filter("xprofile_group_fields","bpdev_filter_profile_fields_by_usertype",10,2);
    function bpdev_filter_profile_fields_by_usertype($fields,$group_id){
    
    //only disable these fields on edit page
    if(!bp_is_profile_edit())
    return $fields;
    //please change it with the name of fields you don't want to allow editing
    $field_to_remove=array("User Role");
    $count=count($fields);
    $flds=array();
    for($i=0;$i<$count;$i++){
    if(in_array($fields[$i]->name,$field_to_remove))
    unset($fields[$i]);
    else
    $flds[]=$fields[$i];//doh, I did not remember a way to reset the index, so creating a new array
    }
    return $flds;
    }

    into my bp-costum.php – again above the line ?>.

    It does not work:

    — threre the user role is still changeable:

    http://kampfsportlerinnenneuwied.1a-spielwiese.de/wp-content/uploads/sites/2/2014/09/user_role_still_changeble.jpg

    http://1a-spielwiese.de/members/kampfsportlerinnenneuwied/profile/edit/group/1 causes an redirection error. – The redirection error disappears, when I’m not logged in as kampfsportlerinnenneuwied, rather as superadmin.

    #201130
    ivanguinea
    Participant

    Sorry:

    This is the list of my plugins:
    BackWPup
    Better WordPress Minify
    Breadcrumb NavXT
    Buddypress
    BuddyPress Registration Groups
    Formulario de Contacto 7
    Cookie Law Info
    Gears
    Hide Admin Bar From Non-admins
    Hide User Profile Fields
    LĆ­mitador de intentos de login
    Nav Menu Images
    Paid Memberships Pro
    PMPro Check Levels
    PMPro Customizations
    PMPro Email Templates
    PMPro Register Helper
    Regenerate Thumbnails
    Remove Dashboard Access
    Revolution Slider
    Simple Social Icons
    Editor de Roles
    WordPress SEO
    WP-Optimize
    WPBakery Visual Composer
    WP Google Fonts
    WP Smush.it
    WP Super Cache
    WP User Frontend Pro

    My theme is Klein (http://klein.dunhakdis.me/)

    #194035

    In reply to: Create a group

    jessicana
    Participant

    What I have done is that I used a plugin that hides the admin bar for all the users (logged in and logged out) and users can’t see or use the toolbar. When the user is logged in, s/he can see the profile link in the menu which takes him/her to the default buddyPrss profile and s/he can start from there. That’s why if create group exist under the profile tab (without admin) it would make my life easier.

    The theme I am using is not helping me to go around this and that’s why I was thinking of using a different theme that is BuddyPress ready.

Viewing 25 results - 226 through 250 (of 634 total)
Skip to toolbar