members->admin ) ) {
$bp->members->admin = new self;
}
return $bp->members->admin;
}
/**
* Constructor method.
*
* @since 2.0.0
*/
public function __construct() {
$this->setup_globals();
$this->setup_actions();
}
/**
* Set admin-related globals.
*
* @since 2.0.0
*/
private function setup_globals() {
$bp = buddypress();
// Paths and URLs
$this->admin_dir = trailingslashit( $bp->plugin_dir . 'bp-members/admin' ); // Admin path.
$this->admin_url = trailingslashit( $bp->plugin_url . 'bp-members/admin' ); // Admin URL.
$this->css_url = trailingslashit( $this->admin_url . 'css' ); // Admin CSS URL.
$this->js_url = trailingslashit( $this->admin_url . 'js' ); // Admin CSS URL.
// Capability depends on config.
$this->capability = bp_core_do_network_admin() ? 'manage_network_users' : 'edit_users';
// The Edit Profile Screen id.
$this->user_page = '';
// The Show Profile Screen id.
$this->user_profile = is_network_admin() ? 'users' : 'profile';
// The current user id.
$this->current_user_id = get_current_user_id();
// The user id being edited.
$this->user_id = 0;
// Is a member editing their own profile.
$this->is_self_profile = false;
// The screen ids to load specific css for.
$this->screen_id = array();
// The stats metabox default position.
$this->stats_metabox = new StdClass();
// BuddyPress edit user's profile args.
$this->edit_profile_args = array( 'page' => 'bp-profile-edit' );
$this->edit_profile_url = '';
$this->edit_url = '';
// Data specific to signups.
$this->users_page = '';
$this->signups_page = '';
$this->users_url = bp_get_admin_url( 'users.php' );
$this->users_screen = bp_core_do_network_admin() ? 'users-network' : 'users';
// Specific config: BuddyPress is not network activated.
$this->subsite_activated = (bool) is_multisite() && ! bp_is_network_activated();
// When BuddyPress is not network activated, only Super Admin can moderate signups.
if ( ! empty( $this->subsite_activated ) ) {
$this->capability = 'manage_network_users';
}
}
/**
* Set admin-related actions and filters.
*
* @since 2.0.0
*/
private function setup_actions() {
/** Extended Profile *************************************************
*/
// Enqueue all admin JS and CSS.
add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
// Add some page specific output to the
.
add_action( 'bp_admin_head', array( $this, 'admin_head' ), 999 );
// Add menu item to all users menu.
add_action( 'admin_menu', array( $this, 'admin_menus' ), 5 );
add_action( 'network_admin_menu', array( $this, 'admin_menus' ), 5 );
add_action( 'user_admin_menu', array( $this, 'user_profile_menu' ), 5 );
// Create the Profile Navigation (Profile/Extended Profile).
add_action( 'edit_user_profile', array( $this, 'profile_nav' ), 99, 1 );
add_action( 'show_user_profile', array( $this, 'profile_nav' ), 99, 1 );
// Editing users of a specific site.
add_action( "admin_head-site-users.php", array( $this, 'profile_admin_head' ) );
// Add a row action to users listing.
if ( bp_core_do_network_admin() ) {
add_filter( 'ms_user_row_actions', array( $this, 'row_actions' ), 10, 2 );
add_action( 'admin_init', array( $this, 'add_edit_profile_url_filter' ) );
add_action( 'wp_after_admin_bar_render', array( $this, 'remove_edit_profile_url_filter' ) );
}
// Add user row actions for single site.
add_filter( 'user_row_actions', array( $this, 'row_actions' ), 10, 2 );
// Process changes to member type.
add_action( 'bp_members_admin_load', array( $this, 'process_member_type_update' ) );
/** Signups **********************************************************
*/
if ( is_admin() ) {
// Filter non multisite user query to remove sign-up users.
if ( ! is_multisite() ) {
add_action( 'pre_user_query', array( $this, 'remove_signups_from_user_query' ), 10, 1 );
}
// Reorganise the views navigation in users.php and signups page.
if ( current_user_can( $this->capability ) ) {
$user_screen = $this->users_screen;
/**
* Users screen on multiblog is users, but signups
* need to be managed in the network for this case
*/
if ( bp_is_network_activated() && bp_is_multiblog_mode() && false === strpos( $user_screen, '-network' ) ) {
$user_screen .= '-network';
}
add_filter( "views_{$user_screen}", array( $this, 'signup_filter_view' ), 10, 1 );
add_filter( 'set-screen-option', array( $this, 'signup_screen_options' ), 10, 3 );
}
// Registration is turned on.
add_action( 'update_site_option_registration', array( $this, 'multisite_registration_on' ), 10, 2 );
add_action( 'update_option_users_can_register', array( $this, 'single_site_registration_on' ), 10, 2 );
}
/** Users List - Members Types ***************************************
*/
if ( is_admin() && bp_get_member_types() ) {
// Add "Change type"