-
Author
-
December 12, 2016 at 22:47 #146842RoaderParticipant
Where is Admin here? Is Hidden!
How? Using this php code in functions.php
This is a security measures, because if a hacker see your username, maybe he can try to hack you.
For this reason, you can Hide the Super Admin, and create a General Moderator for your site. In this situation Super Admin is only for Maintenance.
But, this code is incomplete, because it does not hide super admin’s vcard from BuddyPress Widgets.
So, Please, Radu and others, Tell us How we can Hide super admin using php.
<——————– CODE ——————–>
// 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 );
// 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 );
// 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’);
Attachments:
You must be logged in to view attached files.December 13, 2016 at 09:38 #146872LauraModeratorHello, this is not something related to the theme but Buddypress plugin, which is the plugin that handles profiles, member directory, groups…
Said so, there are many topics around buddypress forum regarding this matter, so it will be easy for you to find the answers there 🙂
Such as:
-https://buddypress.org/support/topic/hide-admin-from-members-and-activity/
-https://buddypress.org/support/search/hide+admin+in+directory/Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy to help you 🙂
December 13, 2016 at 21:37 #146954RoaderParticipantQuerida Laura. Yo tomé los códigos de esos enlaces previamente. Pero ahí no aparece cómo esconder el Admin de los WidGets de BP. Por esa razón abrí este Ticket aquí a ver si tú o Radu me ayudan.
December 14, 2016 at 22:14 #147068LauraModeratorHola, prueba https://premium.wpmudev.org/forums/topic/exclude-users-from-buddypress-members-widget
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy to help you 🙂
December 19, 2016 at 06:51 #147394LauraModeratorHola, ahora mismo no hay nada mas 🙁
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy to help you 🙂
December 21, 2016 at 03:16 #147605RoaderParticipantLaura, plis, pídele a Radu que revise, ya que él maneja más el php quizás sepa algo.
December 23, 2016 at 17:36 #147896RaduModeratorHi,
IF that code doesn’t work on BuddyPress widgets ask this on BuddyPress forums since we not change the logic of BuddyPress widgets.
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionDecember 25, 2016 at 03:10 #147952RoaderParticipantFor now the solution is:
#members-list > li:nth-child(1) {
display: none;
}December 25, 2016 at 03:13 #147953RoaderParticipantTheme Options / Styling options / Quick CSS
#members-list > li.vcard:nth-child(1) {
display: none;
}December 25, 2016 at 19:16 #147970RoaderParticipant🙁 bad solution. This css works when you are login using user#1 but, for other user, user#1 is visible (>_<)
I need a Php code for that. Is VERY, VERY important to hide Super Admin or Admins.
December 27, 2016 at 17:13 #148096RaduModeratorHi,
Please see this guide: https://buddydev.com/buddypress/exclude-users-from-members-directory-on-a-buddypress-based-social-network/
It should work.There are more solutions on the web regarding to this, test and find the perfect one for you..
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionDecember 27, 2016 at 21:55 #148130RoaderParticipantFrom Member Directory NOT! I have this solution! (Check the code up)
Is from BuddyPress WIDGETS the big problem!
Please!
December 27, 2016 at 22:00 #148131RoaderParticipantNow I go to try this… and I tell you later. https://buddydev.com/buddypress/hiding-users-on-buddypress-based-site/
My friend Radu, you know, WordPress needs a lot of Security… and BuddyPress MORE!
December 28, 2016 at 00:53 #148140RoaderParticipantFULL CODE:::
// Exclude Admins from Directories and BP Widgets
add_filter( ‘bp_after_has_members_parse_args’, ‘buddydev_exclude_users’ );function buddydev_exclude_users( $args ) {
//do not exclude in admin
if( is_admin() && ! defined( ‘DOING_AJAX’ ) ) {
return $args;
}$excluded = isset( $args[‘exclude’] )? $args[‘exclude’] : array();
if( !is_array( $excluded ) ) {
$excluded = explode(‘,’, $excluded );
}$user_ids = array( 1, ); // enter user ids here, separated by comma
$excluded = array_merge( $excluded, $user_ids );
$args[‘exclude’] = $excluded;
return $args;
}// 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 );// 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 );December 28, 2016 at 00:54 #148141RoaderParticipantCOPY CODE<strong>FULL CODE:::</strong> // Exclude Admins from Directories and BP Widgets add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users' ); function buddydev_exclude_users( $args ) { //do not exclude in admin if( is_admin() && ! defined( 'DOING_AJAX' ) ) { return $args; } $excluded = isset( $args['exclude'] )? $args['exclude'] : array(); if( !is_array( $excluded ) ) { $excluded = explode(',', $excluded ); } $user_ids = array( 1, ); // enter user ids here, separated by comma $excluded = array_merge( $excluded, $user_ids ); $args['exclude'] = $excluded; return $args; } // 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 ); // 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 );
December 28, 2016 at 01:06 #148144RoaderParticipantOTHER CODE::::
COPY CODE// 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');
-
AuthorPosts
You must be logged in to reply to this topic.