Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'Hide Admin'

Viewing 25 results - 301 through 325 (of 691 total)
  • Author
    Search Results
  • #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.

    #193476
    danbp
    Participant

    @jessicana,

    The field NAME in the field group BASE is required. This group is used for the registration page to work. As you already know, it’s also this group who allows you to show custom fields on the registration page.
    The NAME field in BuddyPress is intended to receive first and last name and replace the two original fields (first name, last name) coming with WordPress.

    That said, you can hide this field to users, but you can’t give them the choice to show/hide it.

    The above snippet will hide the field NAME to all visitors/members, but not to site admin and the concerned profile.

    function bpfr_make_name_members_only( $retval ) {	
    	//hold all of our info
    	global $bp;
    	
    	// is xprofile component active ?	
    	if ( bp_is_active( 'xprofile' ) )
    	
        // The user ID of the currently logged in user
        $current_user_id = (int) trim($bp->loggedin_user->id);
    	
        // The author that we are currently viewing
        $author_id  = (int) trim($bp->displayed_user->id);
    	
    	// user can see only his name && admin can see everyone 
    	if ($current_user_id !== $author_id && !current_user_can('delete_others_pages') ) {
    		$retval['exclude_fields'] = '1';	
    	}
    	return $retval;	
    }
    add_filter( 'bp_after_has_profile_parse_args', 'bpfr_make_name_members_only' );

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

    #190941
    aghajoon
    Participant

    this code work for me but java script not work and when user favorite comment user can’t remove notification help me

    define("BP_FAVORITE_NOTIFIER_SLUG","fa_notification");
    
        function bp_favorite_setup_globals() {	
    	global $bp, $current_blog;
        $bp->bp_favorite=new stdClass();
        $bp->bp_favorite->id = 'bp_favorite';
        $bp->bp_favorite->slug = BP_FAVORITE_NOTIFIER_SLUG;
        $bp->bp_favorite->notification_callback = 'bp_favorite_format_notifications';//show the notification   
        $bp->active_components[$bp->bp_favorite->id] = $bp->bp_favorite->id;
    			
                do_action( 'bp_favorite_setup_globals' );
        }
                add_action( 'bp_setup_globals', 'bp_favorite_setup_globals' );
         
    
    function bp_favorite_format_notifications(  $action, $activity_id, $secondary_item_id, $total_items,$format='string'  ) { 
    $action_checker = explode('_', $action);
    $activities = bp_activity_get_specific( array( 'activity_ids' => $activity_id, 'display_comments' => true) );
    	$glue = '';
    	$user_names = array();
    
    	$users = find_favorite_involved_persons($activity_id, $action);
    	$total_user = $count = count($users);
    
    	if($count > 2) {
    		$users = array_slice($users, $count - 2);
    		$count = $count - 2;
    		$glue = ", ";
    	} else if($total_user == 2) {
    		$glue = " and ";
    	}
    
    	foreach((array)$users as $user_id) {
    		$user_names[] = bp_core_get_user_displayname($user_id);
    	}
    
    	if(!empty($user_names)) {
    		$favoriting_users = join($glue, $user_names);
    	}
    
    	switch ( $action ) {
    		case 'new_bp_favorite_'.$activity_id:
    			if($total_user > 2) {
    				$text = $favoriting_users.' and '.$count.' liked: '.substr($activities["activities"][0]->content,0,32).'...';
    			} else {
    				$text = $favoriting_users." like: ".substr($activities["activities"][0]->content,0,32)."...";
    			}
    		break;
    	}
    	$url = '<div id="'.$action.'"class="notification"><a href="#" class="social-delete" onclick="deleteAjaxNotification(\''.$action.'\',\''.$activity_id.'\', \''.admin_url( 'admin-ajax.php' ).'\'); return false;">x</a><span class="social-loader"></span></div>';
    	$link = favorite_activity_get_permalink( $activity_id );
    
    	if($format=='string') {
    		return apply_filters( 'bp_activity_multiple_favorite_notifications', '<a href="' . $link. '">' . $text . '</a>'. $url .'' ,$users, $total_user, $count, $glue, $link );
    	} else {
    		return array(
    			'link' => $link,
    			'text' => $text
    		);
    	}
    	return false;
    
    }
    function find_favorite_involved_persons($activity_id, $action) {
    	global $bp,$wpdb;
    	$table = $wpdb->prefix . 'bp_notifications';
    	return $wpdb->get_col($wpdb->prepare("select DISTINCT(secondary_item_id) from {$table} where item_id=%d and secondary_item_id!=%d and component_action = %s",$activity_id,$bp->loggedin_user->id, $action));
    }
    function favorite_activity_get_permalink( $activity_id, $activity_obj = false ) {
    	global $bp;
    
    	if ( !$activity_obj )
    		$activity_obj = new BP_Activity_Activity( $activity_id );
                        
    		if ( 'activity_comment' == $activity_obj->type )
    			$link = bp_get_activity_directory_permalink(). 'p/' . $activity_obj->item_id . '/';
    		else
    			$link = bp_get_activity_directory_permalink() . 'p/' . $activity_obj->id . '/';
    
    	return apply_filters( 'ac_notifier_activity_get_permalink', $link );
    
    }
    
    function favorite_notifier_remove_notification($activity ,$has_access){
           global $bp;
           if($has_access)		       
    	   bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->bp_favorite->id, 'new_bp_favorite_'.$activity->id );
    	}
    add_action("bp_activity_screen_single_activity_permalink","favorite_notifier_remove_notification", 10,2);
    
    function favorite_notification( $activity_id){  
                       global $bp;                 
    	               $activities = bp_activity_get_specific( array( 'activity_ids' => $activity_id, 'display_comments' => true) );
    				   $author_id = $activities['activities'][0]->user_id;
                       $user_id =  bp_loggedin_user_id();
    	// if favoriting own activity, dont send notification
    	if( $user_id == $author_id ) {
    		return false;
    	}
    				   if ( bp_is_active( 'notifications' ) ) {
    		bp_notifications_add_notification( array(
    			'user_id'           => $author_id,
    			'item_id'           => $activity_id,
    			'secondary_item_id' => $user_id,
    			'component_name'    => $bp->bp_favorite->id,
    			'component_action'  => 'new_bp_favorite_'.$activity_id,
    			'date_notified'     => bp_core_current_time(),
    			'is_new'            => 1,
    		) );
    	}				
    }
    add_action("bp_activity_add_user_favorite","favorite_notification", 10, 2);
    
    function deleteAjaxNotification(){
        global $bp;        
        bp_core_delete_notifications_by_item_id ($bp->loggedin_user->id, $bp->bp_favorite->id, 'new_bp_favorite_'.$activity->id);     
        die();        
    }	
    add_action('wp_ajax_deleteAjaxNotification', 'deleteAjaxNotification' ); 
    
    function bp_like_add_like_action() {
    global $bp, $activities_template; 
    	 if ( bp_activity_can_favorite() ) : 
    		
    				$my_fav_count = bp_activity_get_meta( bp_get_activity_comment_id(), 'favorite_count' );
    				
    				$my_fav_count = "<span>".$my_fav_count."</span>";
    				
    				$is_favorite = apply_filters( 'bp_get_activity_is_favorite', in_array( bp_get_activity_comment_id(), $activities_template->my_favs ) );
    		
    
    			 if ( !$is_favorite ) : ?>
    
    				<a href="<?php echo apply_filters( 'bp_get_activity_favorite_link', wp_nonce_url( home_url( bp_get_activity_root_slug() . '/favorite/' . bp_get_activity_comment_id() . '/' ), 'mark_favorite' ) ); ?>" class="tooltip-trigger fav bp-secondary-action bp-primary-action" title="<?php _e( 'Favorite', 'buddypress' ); ?>" style="position:relative;"><?php _e( 'Favorite', 'buddypress' ); ?><?php echo $my_fav_count; ?></a>
    
    			<?php else : ?>
    
    				<a href="<?php echo apply_filters( 'bp_get_activity_favorite_link', wp_nonce_url( home_url( bp_get_activity_root_slug() . '/favorite/' . bp_get_activity_comment_id() . '/' ), 'mark_favorite' ) ); ?>" class="tooltip-trigger unfav bp-secondary-action bp-primary-action" title="<?php _e( 'Remove Favorite', 'buddypress' ); ?>" style="position:relative;"><?php _e( 'Remove Favorite', 'buddypress' ); ?><?php echo $my_fav_count; ?></a>
    
    			<?php endif; 
    
    		 endif; 
    }
    add_filter( 'bp_activity_comment_options' , 'bp_like_add_like_action', 1000 );
    
    

    and java code

    function deleteAjaxNotification(action_id, activity_id, adminUrl){
        jQuery('#'+action_id).children(".social-delete").html("");
        jQuery('#'+action_id ).children(".social-loader").show(); 
    
        jQuery.ajax({
            type: 'post',
            url: adminUrl,
            data: { action: "deleteAjaxNotification", action_id:action_id, activity_id:activity_id },
            success:
            function(data) {
            	jQuery('#'+action_id).parent().hide();
            	
            }
         });  
    }
    #190874
    danbp
    Participant

    hi @canadadre,

    you have to read the mentionnedd topic AND to follow the links if the topic contains some. 😉

    i hope for you that you know how to copy/paste, because the above snippets must be added to your child-theme functions.php, or better into bp-custom.php

    1. – Deny access to admins profile

    // 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 );

    2. – Remove admin from the member directory and recount members

    
    // 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');

    3. – Hide admin’s activities from all activity feeds

    // 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 );

    May this help !

    #190864
    Andrea Reed
    Participant

    @danbp I look through your links but don’t see the answer to what I’m looking for. I basically want to hide the Administrator’s profile completely from the front end of the site.

    shanebp
    Moderator

    I wouldn’t rely on messing with visibility settings.
    To make a profile field only editable by admins, do this in bp-custom.php or a plugin:

    // only admins can edit the Skills field
    function chief_hide_profile_fields( $retval ) {
    	
    	if( is_super_admin () )
    		return $retval;
    
    	if(  bp_is_profile_edit() || bp_is_register_page() )
    		$retval['exclude_fields'] = '3';	//profile field ID's separated by comma
    
    	return $retval;
    
    }
    add_filter( 'bp_after_has_profile_parse_args', 'chief_hide_profile_fields' );

    Note that you need to add the correct id(s) for exclude_fields.
    And that ‘ || bp_is_register_page() ‘ keeps the field(s) off the register page – which you may not need to do.

    Re how to create profile fields in code, there a couple of ways to do it depending on the kind of field and how it will be used.
    Take a look at these plugins for more info:
    https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/
    https://wordpress.org/plugins/buddypress-xprofile-image-field/

    #188599
    Jean-Pierre Michaud
    Participant

    i know some guys do not like codecanyon and the likes, but here is a guess on what you did not search yet:

    http://codecanyon.net/search?utf8=%E2%9C%93&category=wordpress&term=hide+admin

    #188563
    danbp
    Participant

    hi @canadadre,

    already asked and answered many times.
    https://buddypress.org/support/search/Hide+Admin/

    And the most recent answer with a partial solution is here:
    https://buddypress.org/support/topic/overwrite-whos-online-widget-theme/

    Partial means you have to complete the work, by using the same method, as the given example concern only one core widget, and not the 2 other (the 4th is the registration widget).

    #188504
    danbp
    Participant

    Another snippet, more accurate with the suggested way above. Snippet goes into bp-custom or functions.php

    The field/field group is only shown to site admins. A small bug in the current BP version(.0 -> 2.0.2) prevent of completely remove the group tab from the edit screen. Bug is fixed and this will work with BP 2.1.

    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'] = '60';  
    		//exlude groups, separated by comma - this may work with BP 2.1
    		$retval['exclude_groups'] = '7'; 			
    	} 
    	return $retval;		
    	
    	endif;
    }
    add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_field_group' );
    #188500
    danbp
    Participant

    @csimpson,

    oh crossposting ! haven’t seen henry’s answer.

    nobody visibility doesn’t exist. This setting is called “only me“. This means that only the member can see this field – and the site admins. Such fields are not for site admins, but for the members !

    I don’t really understand what is not working for you, as what you’re looking for doesn’t exist in BuddyPress. Sorry if i’m misunderstanding you.

    When you create such a field visibility, you should also set “Enforce the default visibility for all members“, so the member cannot modify it later on his profile settings.

    Little weird side effect, when a “only me” field is used and member A wrote hello, this word becames clickabke, by default. When member B write also hello, it becames also clickable. And if A or B clcik on Hello, it shows a list of all members who wrote the same word. In this case A and B !

    Not really confidential, isn’t it ? The solution is to remove the clickable link.
    Here’s a snippet which let you do that selectively.

    function my_xprofile_filter_link_profile_data( $field_value, $field_type = 'textbox' ) {
        // Access the field you are going to display value.
        global $field;
    	
        // In this array you write the ids of the fields you want to hide the link.
        $excluded_field_ids = array(2,9,54); // field ID separated by comma
    	
        // If the id of this $field is in the array, we return the value only and not the link.
        if (in_array($field->id, $excluded_field_ids))
    	return $field_value;
    
    	if ( 'datebox' == $field_type )
    	return $field_value;
    	
    	if ( !strpos( $field_value, ',' ) && ( count( explode( ' ', $field_value ) ) > 5 ) )
    	return $field_value;
    	
    	$values = explode( ',', $field_value );
    
    	if ( !empty( $values ) ) {
    		foreach ( (array) $values as $value ) {
    			$value = trim( $value );
    			
    			// If the value is a URL, skip it and just make it clickable.
    			if ( preg_match( '@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', $value ) ) {
    				$new_values[] = make_clickable( $value );
    				
    				// Is not clickable
    			} else {
    				
    				// More than 5 spaces
    				if ( count( explode( ' ', $value ) ) > 5 ) {
    					$new_values[] = $value;
    					
    					// Less than 5 spaces
    				} else {
    					$search_url   = add_query_arg( array( 's' => urlencode( $value ) ), bp_get_members_directory_permalink() );
    					$new_values[] = '<a href="' . $search_url . '" rel="nofollow">' . $value . '</a>';
    				}
    			}
    		}
    		
    		$values = implode( ', ', $new_values );
    	}
    	
    	return $values;
    }
    
    /**
     * We remove the buddypress filter and add our custom filter.
     */
    function remove_xprofile_links() {
        // Remove the old filter.
        remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 );
        // Add your custom filter.
        add_filter( 'bp_get_the_profile_field_value', 'my_xprofile_filter_link_profile_data', 9, 2);
    }
    add_action('bp_setup_globals', 'remove_xprofile_links');
    #188499
    Henry Wright
    Moderator

    I think the field visibility settings are applicable to the member who is performing the setting.

    The suggested way to do what you want would be to make your notes profile field hidden to all non-admin members.

    The first step would be to create /wp-content/themes/your-theme/buddypress/members/single/profile/edit.php inside your theme.

    You can copy the contents of edit.php from:

    bp-templates/bp-legacy/buddypress/members/single/profile/edit.php

    Then you need to modify edit.php. In edit.php, find <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> and add the following immediately after it:

    if ( ! current_user_can( 'manage_options' ) && ( bp_get_the_profile_field_name() === 'notes' ) )
        continue;

    Note: I’m assuming your field name is notes

    #185851
    pstidsen
    Participant

    Hi danbp

    I have now inserted all of your code in functinos.php, but the only place the admin user disappear is at the “All users”-page. The admin user still shows up at the group members pages and the front page where I have listed all members with the Bowe code plugin.

    I need to hide the admin from the entire site.

    #185618
    danbp
    Participant

    @ganzuelo

    scrolling down the member page provides a funny elastic effect ! 😉 Really cool, but not what you want of course.
    I disabled js on the browser and the effect disapeared immediatly.
    So i think there is a js conflict, probably with some of your theme’s script.
    check for the elements
    `<div class=”col span_3>
    <a>
    <img alt=”Foxtrot Tango” /> `

    You mention salient to be your theme but the source code indicates castle ? Did you rename it for a child theme usage ?
    Some script don’t support this…

    You use also a plugin to remove the admin bar.

    <!--Plugin Global Hide Admin Tool Bar 1.6.1 Build 2014-04-16 Active --->
    <!-- This website is patched against a big problem not solved from WordPress 3.3+ to date -->

    Huh ?

    Don’t know if the second comment belongs to that plugin, but if yes, WP is currently in 4.0 phase, so a 3.3 “problem” maybe solved.
    Google to find a simplier solution to remove the toolbar. There is also a easy and light solution in on the WP codex.

    add_filter('show_admin_bar', '__return_false'); in theme’s function or bp-custom.php would do the job on front-end !

    Don’t use a hammer to kill a fly ! 😉

    #185464
    jejemo
    Participant

    Thanks for you help !

    Actually I hide the admin bar on my pages. That’s the reason why I’m trying to build the exact same menu on another navigation bar.

    I feel like it is a bug because here, it says that :

    $bp->bp_nav “is the array used to render each component navigation menu item for the logged in user”

    and

    $bp->bp_options_nav “is the array used to render all of the sub navigation items for the $bp->bp_nav array”.

    Actually I feel like I’m having the result of $bp->bp_users_nav.
    Because it “is the array used to render each component navigation menu item for the displayed user (when you view a user that is not you).”

    What do you guys think ?

    @mercime
    Participant

    or have I somehow done something to hide it from non-admins?


    @fakename014
    Either via some function in your custom theme or a plugin. To confirm which, change to the Twenty Fourteen theme and check if the adminbar shows up. If it still isn’t showing up, deactivate all plugins to check which one is causing the issue.

    #184252
    nirgalo
    Participant

    Hi, I wanted to also hide admin from the “last activity” widget. I did an override of bp-core/bp-core-widget.php in my theme but it was not taken into account. However if I directly modify bp-core-widget.php in the BP plugin directory, then in works. Too bad the override doesn’t work, I guess I need to create my own widget…

    #184166
    nirgalo
    Participant

    Thanks mercime. However what I’d like is to hide the admin from the Members page only but not disable its activity, as sometimes it needs to post a few notes.

    #184164
    @mercime
    Participant
    #183895
    Netz
    Participant

    Hi!
    Ehhh any functions.php ?? Themes, BP or in a specific folder?

    Running WP 3.9.1 and BP 2.0.1

    I also want to remove “HOME” in BP
    So the result should be first MENU Item is “FORUM” then “MEMBERS” “SEND INVITATIONS” and “ADMIN” (for admins only)

    As default the menu is :
    “HOME” then “FORUM” then “MEMBERS” “SEND INVITATIONS” and “ADMIN” (for admins only)

    But users that get’s in at the “HOME” level post messages thinking they are posting in the FORUM…? So that is why I want to hide it or take it off!

    Hope this solution works – But are unsure where to stick it… 🙂

    Best regards

    Nets

Viewing 25 results - 301 through 325 (of 691 total)
Skip to toolbar