Ticket #5197: 5197.01.diff
File 5197.01.diff, 57.1 KB (added by , 11 years ago) |
---|
-
bp-blogs/bp-blogs-functions.php
970 970 add_action( 'wpmu_delete_user', 'bp_blogs_remove_data' ); 971 971 add_action( 'delete_user', 'bp_blogs_remove_data' ); 972 972 add_action( 'bp_make_spam_user', 'bp_blogs_remove_data' ); 973 974 /** 975 * Displays the number of blogs in user's Admin Profile 976 * 977 * @param integer $user_id the id of user displayed 978 * @return string html stats output 979 */ 980 function bp_blogs_admin_profile_stats( $user_id = 0 ) { 981 if ( ! is_multisite() ) 982 return false; 983 984 if ( $blogs_amount = bp_blogs_total_blogs_for_user( $user_id ) ) { 985 ?> 986 <li><div class="dashicons dashicons-blogs"></div> <?php printf( _n( '1 site', '<strong>%s</strong> sites', $blogs_amount, 'buddypress' ), $blogs_amount );?></li> 987 <?php 988 } 989 } 990 add_action( 'bp_members_admin_user_stats', 'bp_blogs_admin_profile_stats', 12, 1 ); -
bp-friends/bp-friends-functions.php
546 546 add_action( 'wpmu_delete_user', 'friends_remove_data' ); 547 547 add_action( 'delete_user', 'friends_remove_data' ); 548 548 add_action( 'bp_make_spam_user', 'friends_remove_data' ); 549 550 /** 551 * Displays the number of friends in user's Admin Profile 552 * 553 * @param integer $user_id the id of user displayed 554 * @return string html stats output 555 */ 556 function friends_admin_profile_stats( $user_id = 0 ) { 557 if ( $friends_amount = friends_get_total_friend_count( $user_id ) ) { 558 ?> 559 <li><div class="dashicons dashicons-friends"></div> <?php printf( _n( '1 friend', '<strong>%s</strong> friends', $friends_amount, 'buddypress' ), $friends_amount );?></li> 560 <?php 561 } 562 } 563 add_action( 'bp_members_admin_user_stats', 'friends_admin_profile_stats', 10, 1 ); -
bp-groups/bp-groups-functions.php
1056 1056 add_action( 'wpmu_delete_user', 'groups_remove_data_for_user' ); 1057 1057 add_action( 'delete_user', 'groups_remove_data_for_user' ); 1058 1058 add_action( 'bp_make_spam_user', 'groups_remove_data_for_user' ); 1059 1060 1061 /** 1062 * Displays the number of groups in user's Admin Profile 1063 * 1064 * @param integer $user_id the id of user displayed 1065 * @return string html stats output 1066 */ 1067 function groups_admin_profile_stats( $user_id = 0 ) { 1068 if ( $groups_amount = bp_get_total_group_count_for_user( $user_id ) ) { 1069 ?> 1070 <li><div class="dashicons dashicons-groups"></div> <?php printf( _n( '1 group', '<strong>%s</strong> groups', $groups_amount, 'buddypress' ), $groups_amount );?></li> 1071 <?php 1072 } 1073 } 1074 add_action( 'bp_members_admin_user_stats', 'groups_admin_profile_stats', 11, 1 ); -
bp-members/admin/css/admin.css
1 /**** BP Members Profile Administration Screens ****/ 2 3 div#profile-page.wrap form#your-profile { 4 position:relative; 5 } 6 7 div#profile-page.wrap form#your-profile h3:first-of-type { 8 margin-top:6em; 9 } 10 11 div#profile-page.wrap form#your-profile ul#profile-nav { 12 position:absolute; 13 top:-6em; 14 border-bottom:solid 1px #ccc; 15 width:100%; 16 } 17 18 div#community-profile-page h2:first-of-type { 19 margin-bottom:1em; 20 } 21 22 div#community-profile-page h2.profile-section { 23 border-bottom:dotted 1px #ccc; 24 } 25 26 div#community-profile-page ul#profile-nav { 27 border-bottom:solid 1px #ccc; 28 width:100%; 29 margin-top:1em; 30 margin-bottom:1em; 31 padding:1em 0; 32 padding-bottom: 0; 33 height:2.4em; 34 } 35 36 form#your-profile ul#profile-nav li, 37 div#community-profile-page ul#profile-nav li { 38 margin-left:0.4em; 39 float:left; 40 font-weight: bold; 41 font-size: 15px; 42 line-height: 24px; 43 } 44 45 form#your-profile ul#profile-nav li a, 46 div#community-profile-page ul#profile-nav li a { 47 text-decoration: none; 48 color:#888; 49 } 50 51 form#your-profile ul#profile-nav li a:hover, 52 form#your-profile ul#profile-nav li.nav-tab-active a, 53 div#community-profile-page ul#profile-nav li a:hover, 54 div#community-profile-page ul#profile-nav li.nav-tab-active a { 55 text-decoration: none; 56 color:#000; 57 } 58 59 div#community-profile-page div.dashicons-last-active:before { 60 content: "\f130"; 61 } 62 63 div#community-profile-page div.dashicons-friends:before { 64 content: "\f454"; 65 } 66 67 div#community-profile-page div.dashicons-groups:before { 68 content: "\f456"; 69 } 70 71 div#community-profile-page div.dashicons-blogs:before { 72 content: "\f120"; 73 } 74 75 div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar { 76 width:150px; 77 margin:0 auto; 78 } 79 80 div#community-profile-page div#bp_xprofile_user_admin_avatar a { 81 display:block; 82 margin:1em 0; 83 text-decoration:none; 84 color:#888; 85 } 86 87 div#community-profile-page p.not-activated { 88 margin:1em 1em 0; 89 color:red; 90 } 91 92 div#community-profile-page .form-table td.admin-field-visibility-td { 93 padding:5px 5px 15px 5px; 94 } 95 96 div#community-profile-page .form-table tr.admin-field-visibility-tr { 97 border-bottom:dotted 1px #ccc; 98 } 99 100 div#community-profile-page .form-table tr.admin-field-visibility-tr:last-child{ 101 border:none; 102 } 103 104 div#community-profile-page .field-visibility-settings legend, 105 div#community-profile-page .field-visibility-settings-notoggle { 106 font-size: 14px; 107 font-style: italic; 108 color:#666; 109 } 110 111 div#community-profile-page .field-visibility-settings ul { 112 margin:0; 113 font-size: 13px; 114 } 115 116 div#community-profile-page .field-visibility-settings ul li { 117 display:inline-block; 118 margin-right:1em; 119 } -
bp-members/admin/css/admin.min.css
Property changes on: bp-members/admin/css/admin.css ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property
1 div#profile-page.wrap form#your-profile{position:relative}div#profile-page.wrap form#your-profile h3:first-of-type{margin-top:6em}div#profile-page.wrap form#your-profile ul#profile-nav{position:absolute;top:-6em;border-bottom:solid 1px #ccc;width:100%}div#community-profile-page h2:first-of-type{margin-bottom:1em}div#community-profile-page h2.profile-section{border-bottom:dotted 1px #ccc}div#community-profile-page ul#profile-nav{border-bottom:solid 1px #ccc;width:100%;margin-top:1em;margin-bottom:1em;padding:1em 0;padding-bottom:0;height:2.4em}div#community-profile-page ul#profile-nav li,form#your-profile ul#profile-nav li{margin-left:.4em;float:left;font-weight:700;font-size:15px;line-height:24px}div#community-profile-page ul#profile-nav li a,form#your-profile ul#profile-nav li a{text-decoration:none;color:#888}div#community-profile-page ul#profile-nav li a:hover,div#community-profile-page ul#profile-nav li.nav-tab-active a,form#your-profile ul#profile-nav li a:hover,form#your-profile ul#profile-nav li.nav-tab-active a{text-decoration:none;color:#000}div#community-profile-page div.dashicons-last-active:before{content:"\f130"}div#community-profile-page div.dashicons-friends:before{content:"\f454"}div#community-profile-page div.dashicons-groups:before{content:"\f456"}div#community-profile-page div.dashicons-blogs:before{content:"\f120"}div#community-profile-page div#bp_xprofile_user_admin_avatar div.avatar{width:150px;margin:0 auto}div#community-profile-page div#bp_xprofile_user_admin_avatar a{display:block;margin:1em 0;text-decoration:none;color:#888}div#community-profile-page p.not-activated{margin:1em 1em 0;color:red}div#community-profile-page .form-table td.admin-field-visibility-td{padding:5px 5px 15px}div#community-profile-page .form-table tr.admin-field-visibility-tr{border-bottom:dotted 1px #ccc}div#community-profile-page .form-table tr.admin-field-visibility-tr:last-child{border:0}div#community-profile-page .field-visibility-settings legend,div#community-profile-page .field-visibility-settings-notoggle{font-size:14px;font-style:italic;color:#666}div#community-profile-page .field-visibility-settings ul{margin:0;font-size:13px}div#community-profile-page .field-visibility-settings ul li{display:inline-block;margin-right:1em} 2 No newline at end of file -
bp-members/admin/js/admin.js
1 (function( $ ) { 2 3 /** Profile Visibility Settings *********************************/ 4 $('.field-visibility-settings').hide(); 5 $('.visibility-toggle-link').on( 'click', function( event ) { 6 7 event.preventDefault(); 8 9 var toggle_div = $(this).parent(); 10 11 $(toggle_div).fadeOut( 600, function(){ 12 $(toggle_div).siblings('.field-visibility-settings').slideDown(400); 13 }); 14 15 } ); 16 17 $('.field-visibility-settings-close').on( 'click', function( event ) { 18 19 event.preventDefault(); 20 21 var settings_div = $(this).parent(); 22 var vis_setting_text = settings_div.find('input:checked').parent().text(); 23 24 settings_div.slideUp( 400, function() { 25 settings_div.siblings('.field-visibility-settings-toggle').fadeIn(800); 26 settings_div.siblings('.field-visibility-settings-toggle').children('.current-visibility-level').html(vis_setting_text); 27 } ); 28 29 return false; 30 } ); 31 32 })(jQuery); 33 34 35 function clear(container) { 36 if( !document.getElementById(container) ) return; 37 38 var container = document.getElementById(container); 39 40 if ( radioButtons = container.getElementsByTagName('INPUT') ) { 41 for(var i=0; i<radioButtons.length; i++) { 42 radioButtons[i].checked = ''; 43 } 44 } 45 46 if ( options = container.getElementsByTagName('OPTION') ) { 47 for(var i=0; i<options.length; i++) { 48 options[i].selected = false; 49 } 50 } 51 52 return; 53 } 54 No newline at end of file -
bp-members/admin/js/admin.min.js
1 function clear(e){if(!document.getElementById(e))return;var e=document.getElementById(e);if(radioButtons=e.getElementsByTagName("INPUT")){for(var t=0;t<radioButtons.length;t++){radioButtons[t].checked=""}}if(options=e.getElementsByTagName("OPTION")){for(var t=0;t<options.length;t++){options[t].selected=false}}return}(function(e){e(".field-visibility-settings").hide();e(".visibility-toggle-link").on("click",function(t){t.preventDefault();var n=e(this).parent();e(n).fadeOut(600,function(){e(n).siblings(".field-visibility-settings").slideDown(400)})});e(".field-visibility-settings-close").on("click",function(t){t.preventDefault();var n=e(this).parent();var r=n.find("input:checked").parent().text();n.slideUp(400,function(){n.siblings(".field-visibility-settings-toggle").fadeIn(800);n.siblings(".field-visibility-settings-toggle").children(".current-visibility-level").html(r)});return false})})(jQuery) 2 No newline at end of file -
bp-members/bp-members-admin.php
1 <?php 2 // Exit if accessed directly 3 if ( !defined( 'ABSPATH' ) ) exit; 4 5 if ( !class_exists( 'BP_Members_Admin' ) ) : 6 /** 7 * Load Members admin area. 8 * 9 * @package BuddyPress 10 * @subpackage membersAdministration 11 * 12 * @since BuddyPress (2.0.0) 13 */ 14 class BP_Members_Admin { 15 16 /** Directory *************************************************************/ 17 18 /** 19 * Path to the BP Members Admin directory. 20 * 21 * @var string $admin_dir 22 */ 23 public $admin_dir = ''; 24 25 /** URLs ******************************************************************/ 26 27 /** 28 * URL to the BP Members Admin directory. 29 * 30 * @var string $admin_url 31 */ 32 public $admin_url = ''; 33 34 /** 35 * URL to the BP Members Admin CSS directory. 36 * 37 * @var string $css_url 38 */ 39 public $css_url = ''; 40 41 /** 42 * URL to the BP Members Admin JS directory. 43 * 44 * @var string 45 */ 46 public $js_url = ''; 47 48 /** Other *****************************************************************/ 49 50 /** 51 * screen id for edit user's profile page. 52 * 53 * @access public 54 * @var string 55 */ 56 public $user_page = ''; 57 58 /** 59 * Constructor method. 60 * 61 * @access public 62 * @since BuddyPress (2.0.0) 63 */ 64 public function __construct() { 65 $this->setup_globals(); 66 $this->setup_actions(); 67 } 68 69 /** 70 * Set admin-related globals. 71 * 72 * @access private 73 * @since BuddyPress (2.0.0) 74 */ 75 private function setup_globals() { 76 $bp = buddypress(); 77 78 // Paths and URLs 79 $this->admin_dir = trailingslashit( $bp->plugin_dir . 'bp-members/admin' ); // Admin path 80 $this->admin_url = trailingslashit( $bp->plugin_url . 'bp-members/admin' ); // Admin url 81 $this->css_url = trailingslashit( $this->admin_url . 'css' ); // Admin css URL 82 $this->js_url = trailingslashit( $this->admin_url . 'js' ); // Admin css URL 83 84 // The Edit Profile Screen id 85 $this->user_page = ''; 86 87 // The screen ids to load specific css for 88 $this->screen_id = array(); 89 90 // The stats metabox default position 91 $this->stats_metabox = new StdClass(); 92 93 // The WordPress edit user url 94 $this->edit_url = bp_get_admin_url( 'user-edit.php' ); 95 96 // BuddyPress edit user's profile url 97 $this->edit_profile_url = add_query_arg( 'page', 'bp-profile-edit', bp_get_admin_url( 'users.php' ) ); 98 } 99 100 /** 101 * Set admin-related actions and filters. 102 * 103 * @access private 104 * @since BuddyPress (2.0.0) 105 * 106 * @uses add_action() To add various actions. 107 * @uses add_filter() To add various filters. 108 */ 109 private function setup_actions() { 110 111 /** Actions ***********************************************************/ 112 113 // Add some page specific output to the <head> 114 add_action( 'bp_admin_head', array( $this, 'admin_head' ), 999 ); 115 116 // Add menu item to all users menu 117 add_action( bp_core_admin_hook(), array( $this, 'admin_menus' ), 5 ); 118 119 // Enqueue all admin JS and CSS 120 add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 121 122 // Create the Profile Navigation (WordPress/Community) 123 add_action( 'edit_user_profile', array( $this, 'profile_nav' ), 99, 1 ); 124 125 126 /** Filters ***********************************************************/ 127 128 // Add a row action to users listing 129 add_filter( bp_core_do_network_admin() ? 'ms_user_row_actions' : 'user_row_actions', array( $this, 'row_actions' ), 10, 2 ); 130 131 } 132 133 /** 134 * Create the All users Edit Profile submenu 135 * 136 * @access public 137 * @since BuddyPress (2.0.0) 138 * 139 * @uses add_users_page() To add the Edit Profile page in Users section. 140 */ 141 public function admin_menus() { 142 143 // Manage user's profile 144 $hook = $this->user_page = add_users_page( 145 __( 'Edit Profile', 'buddypress' ), 146 __( 'Edit Profile', 'buddypress' ), 147 'bp_moderate', 148 'bp-profile-edit', 149 array( &$this, 'user_admin' ) 150 ); 151 152 $edit_page = 'user-edit'; 153 154 if ( bp_core_do_network_admin() ) { 155 $edit_page .= '-network'; 156 $this->user_page .= '-network'; 157 } 158 159 $this->screen_id = array( $edit_page, $this->user_page ); 160 161 add_action( "admin_head-$hook", array( $this, 'modify_admin_menu_highlight' ) ); 162 add_action( "load-$hook", array( $this, 'user_admin_load' ) ); 163 164 } 165 166 /** 167 * Add some specific styling to the Edit user and Edit user's profile page. 168 * 169 * @access public 170 * @since BuddyPress (2.0.0) 171 */ 172 public function enqueue_scripts() { 173 if ( ! in_array( get_current_screen()->id, $this->screen_id ) ) { 174 return; 175 } 176 177 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 178 179 $css = $this->css_url . "admin{$min}.css"; 180 $css = apply_filters( 'bp_members_admin_css', $css ); 181 wp_enqueue_style( 'bp-members-css', $css, array(), bp_get_version() ); 182 183 $js = $this->js_url . "admin{$min}.js"; 184 $js = apply_filters( 'bp_members_admin_js', $js ); 185 wp_enqueue_script( 'bp-members-js', $js, array( 'jquery' ), bp_get_version(), true ); 186 187 // Plugins may want to hook here to load some css/js 188 do_action( 'bp_members_admin_enqueue_scripts', get_current_screen()->id, $this->screen_id ); 189 } 190 191 /** 192 * Create the Profile navigation in Edit User & Edit Profile pages 193 * 194 * @access public 195 * @since BuddyPress (?) 196 */ 197 public function profile_nav( $user = null, $active = 'WordPress' ) { 198 199 if ( empty( $user->ID ) ) { 200 return; 201 } 202 203 $query_args = array( 'user_id' => $user->ID ); 204 205 if ( ! empty( $_REQUEST['wp_http_referer'] ) ) { 206 $query_args['wp_http_referer'] = urlencode( wp_unslash( $_REQUEST['wp_http_referer'] ) ); 207 } 208 209 $community_url = add_query_arg( $query_args, $this->edit_profile_url ); 210 $wordpress_url = add_query_arg( $query_args, $this->edit_url ); 211 212 $bp_active = false; 213 $wp_active = ' nav-tab-active'; 214 if ( 'BuddyPress' == $active ) { 215 $bp_active = ' nav-tab-active'; 216 $wp_active = false; 217 } 218 219 ?> 220 <ul id="profile-nav" class="nav-tab-wrapper"> 221 <li class="nav-tab<?php echo $wp_active;?>"><a href="<?php echo $wordpress_url;?>"><?php _e( 'WordPress Profile' ); ?></a></li> 222 <li class="nav-tab<?php echo $bp_active;?>"><a href="<?php echo $community_url;?>"><?php _e( 'Community Profile' ); ?></a></li> 223 </ul> 224 <?php 225 } 226 227 /** 228 * Highlight the All users menu if on Edit Profile pages 229 * 230 * @access public 231 * @since BuddyPress (2.0.0) 232 * 233 * @global $plugin_page 234 * @global $submenu_file 235 */ 236 public function modify_admin_menu_highlight() { 237 global $plugin_page, $submenu_file; 238 239 // Only Show the All users menu 240 if ( 'bp-profile-edit' == $plugin_page ) { 241 $submenu_file = 'users.php'; 242 } 243 } 244 245 /** 246 * Remove the Edit Profile submenu page 247 * 248 * @access public 249 * @since BuddyPress (2.0.0) 250 */ 251 public function admin_head() { 252 // Remove submenu to force using Profile Navigation 253 remove_submenu_page( 'users.php', 'bp-profile-edit' ); 254 } 255 256 /** 257 * Set up the User's profile admin page. 258 * 259 * Loaded before the page is rendered, this function does all initial setup, 260 * including: processing form requests, registering contextual help, and 261 * setting up screen options. 262 * 263 * @access public 264 * @since BuddyPress (?) 265 */ 266 public function user_admin_load() { 267 268 if ( ! $user_id = intval( $_GET['user_id'] ) ) { 269 wp_die( __( 'No users were found', 'buddypress' ) ); 270 } 271 272 $bp = buddypress(); 273 274 /** 275 * Sets displayed user id if empty on the user's profile admin page. 276 * this is probably not the right way to do it. But bp_get_the_profile_field_options() args 277 * does not accept a user_id parameter and for instance, bp_displayed_user_id() is used in 278 * BP_XProfile_ProfileData::get_value_byid() to retrieve datas. 279 */ 280 if ( empty( $bp->displayed_user->id ) ) { 281 282 // Let's set the user displayed id 283 $bp->displayed_user->id = $user_id; 284 285 // The domain for the user currently being displayed 286 $bp->displayed_user->domain = bp_core_get_user_domain( bp_displayed_user_id() ); 287 288 // The core userdata of the user who is currently being displayed 289 $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() ); 290 291 // Fetch the full name displayed user 292 $bp->displayed_user->fullname = bp_core_get_user_displayname( bp_displayed_user_id() ); 293 } 294 295 // Build redirection URL 296 $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham', 'delete_avatar' ), $_SERVER['REQUEST_URI'] ); 297 $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : false; 298 299 if ( ! empty( $_REQUEST['user_status'] ) ) { 300 $spam = ( 'spam' == $_REQUEST['user_status'] ) ? true : false ; 301 302 if ( $spam != bp_is_user_spammer( $user_id ) ) { 303 $doaction = $_REQUEST['user_status']; 304 } 305 } 306 307 // Call an action for plugins to hook in early 308 do_action_ref_array( 'bp_members_admin_load', array( $doaction, $_REQUEST ) ); 309 310 // Prepare the display of the Community Profile screen 311 if ( ! in_array( $doaction, array( 'update', 'delete_avatar', 'spam', 'ham' ) ) ) { 312 add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) ); 313 314 get_current_screen()->add_help_tab( array( 315 'id' => 'bp-profile-edit-overview', 316 'title' => __( 'Overview', 'buddypress' ), 317 'content' => 318 '<p>' . __( 'This is the admin view of a user's profile.', 'buddypress' ) . '</p>' . 319 '<p>' . __( 'You can edit the different fields of his extended profile from the main metabox', 'buddypress' ) . '</p>' . 320 '<p>' . __( 'You can get some interesting informations about him on right side metaboxes', 'buddypress' ) . '</p>' 321 ) ); 322 323 // Help panel - sidebar links 324 get_current_screen()->set_help_sidebar( 325 '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . 326 '<p>' . __( '<a href="http://codex.buddypress.org/buddypress-site-administration/managing-user-profiles/">Managing Profiles</a>', 'buddypress' ) . '</p>' . 327 '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>' 328 ); 329 330 // Register metaboxes for the edit screen. 331 add_meta_box( 'submitdiv', _x( 'Status', 'members user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_status_metabox' ), get_current_screen()->id, 'side', 'core' ); 332 333 // In case xprofile is not active 334 $this->stats_metabox->context = 'normal'; 335 $this->stats_metabox->priority = 'core'; 336 337 /** 338 * xProfile Hooks to load the profile fields if component is active 339 * Plugins should not use this hook, please use 'bp_members_admin_user_metaboxes' instead 340 */ 341 do_action_ref_array( 'bp_members_admin_xprofile_metabox', array( $user_id, get_current_screen()->id, $this->stats_metabox ) ); 342 343 // If xProfile is inactive, difficult to know what's profile we're on 344 $display_name = false; 345 if ( 'normal' == $this->stats_metabox->context ) { 346 $display_name = ' - ' . esc_html( $bp->displayed_user->fullname ); 347 } 348 349 // User Stat metabox 350 add_meta_box( 'bp_members_admin_user_stats', _x( 'Stats' . $display_name, 'members user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_stats_metabox' ), get_current_screen()->id, $this->stats_metabox->context, $this->stats_metabox->priority ); 351 352 // Custom metabox ? 353 do_action( 'bp_members_admin_user_metaboxes' ); 354 355 // Enqueue javascripts 356 wp_enqueue_script( 'postbox' ); 357 wp_enqueue_script( 'dashboard' ); 358 wp_enqueue_script( 'comment' ); 359 360 // Spam or Ham user 361 } else if ( in_array( $doaction, array( 'spam', 'ham' ) ) ) { 362 363 check_admin_referer( 'edit-bp-profile_' . $user_id ); 364 365 if ( bp_core_process_spammer_status( $user_id, $doaction ) ) { 366 $redirect_to = add_query_arg( 'updated', $doaction, $redirect_to ); 367 } else { 368 $redirect_to = add_query_arg( 'error', $doaction, $redirect_to ); 369 } 370 371 bp_core_redirect( $redirect_to ); 372 373 // Update other stuff once above ones are done 374 } else { 375 $this->redirect = $redirect_to; 376 377 do_action_ref_array( 'bp_members_admin_update_user', array( $doaction, $user_id, $_REQUEST, $this->redirect ) ); 378 379 bp_core_redirect( $this->redirect ); 380 } 381 } 382 383 /** 384 * Display the user's profile. 385 * 386 * @access public 387 * @since BuddyPress (?) 388 */ 389 public function user_admin() { 390 391 if ( ! current_user_can( 'bp_moderate' ) ) { 392 die( '-1' ); 393 } 394 395 $user = get_user_to_edit( $_GET['user_id'] ); 396 397 // Construct URL for form 398 $form_url = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham' ), $_SERVER['REQUEST_URI'] ); 399 $form_url = add_query_arg( 'action', 'update', $form_url ); 400 $wp_http_referer = remove_query_arg( array( 'action', 'updated' ), $_REQUEST['wp_http_referer'] ); 401 402 // Prepare notice for admin 403 $notice = array(); 404 405 if ( ! empty( $_REQUEST['updated'] ) ) { 406 switch ( $_REQUEST['updated'] ) { 407 case 'avatar': 408 $notice = array( 409 'class' => 'updated', 410 'message' => __( 'Avatar was deleted successfully!', 'buddypress' ) 411 ); 412 break; 413 case 'ham' : 414 $notice = array( 415 'class' => 'updated', 416 'message' => __( 'User removed as spammer.', 'buddypress' ) 417 ); 418 break; 419 case 'spam' : 420 $notice = array( 421 'class' => 'updated', 422 'message' => __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) 423 ); 424 break; 425 case 1 : 426 $notice = array( 427 'class' => 'updated', 428 'message' => __( 'Profile updated.', 'buddypress' ) 429 ); 430 break; 431 } 432 } 433 434 if ( ! empty( $_REQUEST['error'] ) ) { 435 switch ( $_REQUEST['error'] ) { 436 case 'avatar': 437 $notice = array( 438 'class' => 'error', 439 'message' => __( 'There was a problem deleting that avatar, please try again.', 'buddypress' ) 440 ); 441 break; 442 case 'ham' : 443 $notice = array( 444 'class' => 'error', 445 'message' => __( 'User could not be removed as spammer.', 'buddypress' ) 446 ); 447 break; 448 case 'spam' : 449 $notice = array( 450 'class' => 'error', 451 'message' => __( 'User could not be marked as spammer.', 'buddypress' ) 452 ); 453 break; 454 case 1 : 455 $notice = array( 456 'class' => 'error', 457 'message' => __( 'An error occured while trying to update the profile.', 'buddypress' ) 458 ); 459 break; 460 case 2: 461 $notice = array( 462 'class' => 'error', 463 'message' => __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ) 464 ); 465 break; 466 case 3: 467 $notice = array( 468 'class' => 'error', 469 'message' => __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' ) 470 ); 471 break; 472 } 473 } 474 475 if ( ! empty( $notice ) ) : 476 if ( 'updated' === $notice['class'] ) : ?> 477 <div id="message" class="<?php echo esc_attr( $notice['class'] ); ?>"> 478 <?php else: ?> 479 <div class="<?php echo esc_attr( $notice['class'] ); ?>"> 480 <?php endif; ?> 481 <p><?php echo $notice['message']; ?></p> 482 <?php if ( !empty( $wp_http_referer ) && ( 'updated' === $notice['class'] ) ) : ?> 483 <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e( '← Back to Users', 'buddypress' ); ?></a></p> 484 <?php endif; ?> 485 </div> 486 <?php endif; ?> 487 488 <div class="wrap" id="community-profile-page"> 489 <?php screen_icon( 'users' ); ?> 490 <h2> 491 <?php 492 _e( 'Edit User', 'buddypress' ); 493 if ( current_user_can( 'create_users' ) ) { ?> 494 <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user', 'buddypress' ); ?></a> 495 <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> 496 <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user', 'buddypress' ); ?></a> 497 <?php } 498 ?> 499 </h2> 500 501 <?php if ( ! empty( $user ) ) : 502 503 $this->profile_nav( $user, 'BuddyPress' ); ?> 504 505 <form action="<?php echo esc_attr( $form_url ); ?>" id="your-profile" method="post"> 506 <div id="poststuff"> 507 508 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> 509 <div id="post-body-content"> 510 </div><!-- #post-body-content --> 511 512 <div id="postbox-container-1" class="postbox-container"> 513 <?php do_meta_boxes( get_current_screen()->id, 'side', $user ); ?> 514 </div> 515 516 <div id="postbox-container-2" class="postbox-container"> 517 <?php do_meta_boxes( get_current_screen()->id, 'normal', $user ); ?> 518 <?php do_meta_boxes( get_current_screen()->id, 'advanced', $user ); ?> 519 </div> 520 </div><!-- #post-body --> 521 522 </div><!-- #poststuff --> 523 524 <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> 525 <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> 526 <?php wp_nonce_field( 'edit-bp-profile_' . $user->ID ); ?> 527 528 </form> 529 530 <?php else : ?> 531 <p><?php printf( __( 'No user found with this ID. <a href="%s">Go back and try again</a>.', 'buddypress' ), esc_url( bp_get_admin_url( 'users.php' ) ) ); ?></p> 532 <?php endif; ?> 533 534 </div><!-- .wrap --> 535 <?php 536 } 537 538 /** 539 * Renders the Status metabox for user's profile screen. 540 * 541 * Actions are : 542 * - Update profile fields if xProfile component is active 543 * - Spam/Unspam user 544 * 545 * @access public 546 * @since BuddyPress (2.0.0) 547 * 548 * @param WP_User $user The WP_User object for the user's profile to edit 549 */ 550 public function user_admin_status_metabox( $user = null ) { 551 552 // bail if no user id or if the user has not activated his account yet.. 553 if ( empty( $user->ID ) ) { 554 return; 555 } 556 557 558 if ( ( isset( $user->user_status ) && 2 == $user->user_status ) ) { 559 echo '<p class="not-activated">' . sprintf( 'User has not activated his account yet', 'buddypress' ) . '</p><br/>'; 560 return; 561 } 562 ?> 563 564 <div class="submitbox" id="submitcomment"> 565 <div id="minor-publishing"> 566 <div id="minor-publishing-actions"> 567 <div id="preview-action"> 568 <a class="button preview" href="<?php echo esc_attr( bp_core_get_user_domain( $user->ID ) ); ?>" target="_blank"><?php _e( 'View Profile', 'buddypress' ); ?></a> 569 </div> 570 571 <div class="clear"></div> 572 </div><!-- #minor-publishing-actions --> 573 574 <div id="misc-publishing-actions"> 575 <div class="misc-pub-section" id="comment-status-radio"> 576 <label class="approved"><input type="radio" name="user_status" value="ham" <?php checked( bp_is_user_spammer( $user->ID ), false ); ?>><?php _e( 'Active', 'buddypress' ); ?></label><br /> 577 <label class="spam"><input type="radio" name="user_status" value="spam" <?php checked( bp_is_user_spammer( $user->ID ), true ); ?>><?php _e( 'Spammer', 'buddypress' ); ?></label> 578 </div> 579 580 <div class="misc-pub-section curtime misc-pub-section-last"> 581 <?php 582 // translators: Publish box date format, see http://php.net/date 583 $datef = __( 'M j, Y @ G:i', 'buddypress' ); 584 $date = date_i18n( $datef, strtotime( $user->user_registered ) ); 585 ?> 586 <span id="timestamp"><?php printf( __( 'Registered on: <strong>%1$s</strong>', 'buddypress' ), $date ); ?></span> 587 588 <div id='timestampdiv' class='hide-if-js'> 589 <?php touch_time( 1, 0, 5 ); ?> 590 </div><!-- #timestampdiv --> 591 </div> 592 </div> <!-- #misc-publishing-actions --> 593 594 <div class="clear"></div> 595 </div><!-- #minor-publishing --> 596 597 <div id="major-publishing-actions"> 598 <div id="publishing-action"> 599 <?php submit_button( __( 'Update Profile', 'buddypress' ), 'primary', 'save', false, array( 'tabindex' => '4' ) ); ?> 600 </div> 601 <div class="clear"></div> 602 </div><!-- #major-publishing-actions --> 603 604 </div><!-- #submitcomment --> 605 606 <?php 607 } 608 609 /** 610 * Renders the fallback metabox in case a user has been marked as a spammer. 611 * 612 * @access public 613 * @since BuddyPress (2.0.0) 614 * 615 * @param WP_User $user The WP_User object for the user's profile to edit 616 */ 617 public function user_admin_spammer_metabox( $user = null ) { 618 ?> 619 <p><?php printf( __( '%s has been marked as a spammer, this user's BuddyPress datas were removed', 'buddypress' ), bp_core_get_user_displayname( $user->ID ) ) ;?></p> 620 <?php 621 } 622 623 /** 624 * Renders the Stats metabox to moderate inappropriate images. 625 * 626 * @access public 627 * @since BuddyPress (2.0.0) 628 * 629 * @param WP_User $user The WP_User object for the user's profile to edit 630 */ 631 public function user_admin_stats_metabox( $user = null ) { 632 633 if ( empty( $user->ID ) ) { 634 return; 635 } 636 637 // If account is not activated last activity is the time user registered 638 if ( isset( $user->user_status ) && 2 == $user->user_status ) { 639 $last_active = $user->user_registered; 640 // Account is activated, getting user's last activity 641 } else { 642 $last_active = bp_get_user_last_activity( $user->ID ); 643 } 644 645 $datef = __( 'M j, Y @ G:i', 'buddypress' ); 646 $date = date_i18n( $datef, strtotime( $last_active ) ); ?> 647 648 <ul> 649 <li><div class="dashicons dashicons-last-active"></div> <?php printf( __( 'Last active: <strong>%1$s</strong>', 'buddypress' ), $date ); ?></li> 650 651 <?php 652 // Loading other stats only if user has activated his account 653 if ( empty( $user->user_status ) ) { 654 do_action( 'bp_members_admin_user_stats', $user->ID, $user ); 655 } 656 ?> 657 </ul> 658 <?php 659 } 660 661 /** 662 * Adds a link to user's profile in users listing row actions. 663 * 664 * @access public 665 * @since BuddyPress (2.0.0) 666 * 667 * @param array $actions the WordPress row actions (edit, delete) 668 * @param object $user The object for the user's row 669 * @return array merged actions 670 */ 671 public function row_actions( $actions = '', $user = null ) { 672 673 if ( get_current_user_id() === $user->ID ) { 674 return $actions; 675 } 676 677 $edit_profile = add_query_arg( array( 678 'user_id' => $user->ID, 679 'wp_http_referer' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) 680 ), $this->edit_profile_url ); 681 682 $edit_action = $actions['edit']; 683 unset( $actions['edit'] ); 684 685 $new_edit_actions = array( 686 'edit' => $edit_action, 687 'edit-profile' => '<a href="' . esc_url( $edit_profile ) . '">' . __( 'Profile', 'buddypress' ) . '</a>' 688 ); 689 690 return array_merge( $new_edit_actions, $actions ); 691 } 692 693 } 694 695 endif; // class_exists check 696 697 /** 698 * Setup BP Members Admin. 699 * 700 * @since BuddyPress (2.0.0) 701 * 702 * @uses buddypress() to get BuddyPress main instance 703 */ 704 function bp_members_admin() { 705 buddypress()->members->admin = new BP_Members_Admin(); 706 } 707 708 // Load the BP Members admin 709 if( is_admin() ) { 710 add_action( 'bp_init', 'bp_members_admin' ); 711 } -
bp-members/bp-members-functions.php
563 563 remove_action( 'make_spam_user', 'bp_core_mark_user_spam_admin' ); 564 564 remove_action( 'make_ham_user', 'bp_core_mark_user_ham_admin' ); 565 565 566 // When marking as spam in the Dashboard, these actions are handled by WordPress 567 if ( !is_admin() ) { 566 // Determine if we are in an admin page 567 $is_admin = is_admin(); 568 if( $is_admin && ! defined( 'DOING_AJAX' ) ) { 569 $is_admin = (bool) ( buddypress()->members->admin->user_page !== get_current_screen()->id ); 570 } 568 571 572 // When marking as spam in the Dashboard, these actions are handled by WordPress 573 if ( ! $is_admin ) { 574 569 575 // Get the blogs for the user 570 576 $blogs = get_blogs_of_user( $user_id, true ); 571 577 -
bp-members/bp-members-loader.php
45 45 'functions', 46 46 'notifications', 47 47 ); 48 49 if ( is_admin() ) { 50 $includes[] = 'admin'; 51 } 52 48 53 parent::includes( $includes ); 49 54 } 50 55 -
bp-xprofile/bp-xprofile-admin.php
466 466 467 467 <?php 468 468 } 469 470 if ( !class_exists( 'BP_XProfile_User_Admin' ) ) : 471 /** 472 * Load xProfile user's profile admin area. 473 * 474 * @package BuddyPress 475 * @subpackage xProfileAdministration 476 * 477 * @since BuddyPress (2.0.0) 478 */ 479 class BP_XProfile_User_Admin { 480 481 /** 482 * Constructor method. 483 * 484 * @access public 485 * @since BuddyPress (2.0.0) 486 */ 487 public function __construct() { 488 $this->setup_actions(); 489 } 490 491 /** 492 * Set admin-related actions and filters. 493 * 494 * @access private 495 * @since BuddyPress (2.0.0) 496 * 497 * @uses add_action() To add various actions. 498 */ 499 private function setup_actions() { 500 501 /** Actions ***********************************************************/ 502 503 // Register the metabox in Member's community admin profile 504 add_action( 'bp_members_admin_xprofile_metabox', array( $this, 'register_metaboxes' ), 10, 3 ); 505 506 // Saves the profile actions for user ( avatar, profile fields ) 507 add_action( 'bp_members_admin_update_user', array( $this, 'user_admin_load' ), 10, 4 ); 508 509 } 510 511 /** 512 * Register the xProfile metabox in Member's community admin profile page. 513 * 514 * @access public 515 * @since BuddyPress (2.0.0) 516 * 517 * @param integer $user_id the id of the user displayed 518 * @param string $screen_id the screen id to load the metabox in 519 * @param object $stats_metabox the stats metabox context and priority to edit 520 */ 521 public function register_metaboxes( $user_id = 0, $screen_id = '', $stats_metabox = null ) { 522 523 if ( empty( $user_id ) ) { 524 $user_id = bp_displayed_user_id(); 525 } 526 527 if ( empty( $screen_id ) ) { 528 $screen_id = buddypress()->members->admin->user_page; 529 } 530 531 if ( empty( $stats_metabox ) ) { 532 $stats_metabox = new StdClass(); 533 } 534 535 // Moving the Stats Metabox 536 $stats_metabox->context = 'side'; 537 $stats_metabox->priority = 'low'; 538 539 // Each Group of fields will have his own metabox 540 if ( false == bp_is_user_spammer( $user_id ) && bp_has_profile( array( 'fetch_fields' => false ) ) ) { 541 while ( bp_profile_groups() ) : bp_the_profile_group(); 542 add_meta_box( 'bp_xprofile_user_admin_fields_' . bp_get_the_profile_group_slug(), bp_get_the_profile_group_name(), array( &$this, 'user_admin_profile_metaboxes' ), $screen_id, 'normal', 'core', array( 'profile_group_id' => bp_get_the_profile_group_id() ) ); 543 endwhile; 544 545 // if a user has been mark as a spammer, his BuddyPress datas are removed ! 546 } else { 547 add_meta_box( 'bp_xprofile_user_admin_empty_profile', _x( 'User marked as a spammer', 'xprofile user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_spammer_metabox' ), $screen_id, 'normal', 'core' ); 548 } 549 550 // Avatar Metabox 551 add_meta_box( 'bp_xprofile_user_admin_avatar', _x( 'Avatar', 'xprofile user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_avatar_metabox' ), $screen_id, 'side', 'low' ); 552 553 } 554 555 /** 556 * Saves the profile fields in Members community profile page. 557 * 558 * Loaded before the page is rendered, this function is processing form requests 559 * 560 * @access public 561 * @since BuddyPress (2.0.0) 562 */ 563 public function user_admin_load( $doaction = '', $user_id = 0, $request = array(), $redirect_to = '' ) { 564 565 // Eventually delete avatar 566 if ( 'delete_avatar' == $doaction ) { 567 568 check_admin_referer( 'delete_avatar' ); 569 570 $redirect_to = remove_query_arg( '_wpnonce', $redirect_to ); 571 572 if ( bp_core_delete_existing_avatar( array( 'item_id' => $user_id ) ) ) { 573 $redirect_to = add_query_arg( 'updated', 'avatar', $redirect_to ); 574 } else { 575 $redirect_to = add_query_arg( 'error', 'avatar', $redirect_to ); 576 } 577 578 bp_core_redirect( $redirect_to ); 579 580 // Update profile fields 581 } else { 582 // Check to see if any new information has been submitted 583 if ( isset( $_POST['field_ids'] ) ) { 584 585 // Check the nonce 586 check_admin_referer( 'edit-bp-profile_' . $user_id ); 587 588 // Check we have field ID's 589 if ( empty( $_POST['field_ids'] ) ) { 590 $redirect_to = add_query_arg( 'error', '1', $redirect_to ); 591 bp_core_redirect( $redirect_to ); 592 } 593 594 $merge_ids = ''; 595 foreach ( $_POST['field_ids'] as $ids ) { 596 $merge_ids .= $ids . ','; 597 } 598 599 // Explode the posted field IDs into an array so we know which 600 // fields have been submitted 601 $posted_field_ids = array_filter( wp_parse_id_list( $merge_ids ) ); 602 $is_required = array(); 603 604 // Loop through the posted fields formatting any datebox values 605 // then validate the field 606 foreach ( (array) $posted_field_ids as $field_id ) { 607 if ( ! isset( $_POST['field_' . $field_id] ) ) { 608 if ( ! empty( $_POST['field_' . $field_id . '_day'] ) && ! empty( $_POST['field_' . $field_id . '_month'] ) && ! empty( $_POST['field_' . $field_id . '_year'] ) ) { 609 // Concatenate the values 610 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year']; 611 612 // Turn the concatenated value into a timestamp 613 $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) ); 614 } 615 } 616 617 $is_required[ $field_id ] = xprofile_check_is_required_field( $field_id ); 618 if ( $is_required[ $field_id ] && empty( $_POST['field_' . $field_id] ) ) { 619 $redirect_to = add_query_arg( 'error', '2', $redirect_to ); 620 bp_core_redirect( $redirect_to ); 621 } 622 } 623 624 // Set the errors var 625 $errors = false; 626 627 // Now we've checked for required fields, lets save the values. 628 foreach ( (array) $posted_field_ids as $field_id ) { 629 630 // Certain types of fields (checkboxes, multiselects) may come through empty. Save them as an empty array so that they don't get overwritten by the default on the next edit. 631 if ( empty( $_POST['field_' . $field_id] ) ) { 632 $value = array(); 633 } else { 634 $value = $_POST['field_' . $field_id]; 635 } 636 637 if ( ! xprofile_set_field_data( $field_id, $user_id, $value, $is_required[ $field_id ] ) ) { 638 $errors = true; 639 } else { 640 do_action( 'xprofile_profile_field_data_updated', $field_id, $value ); 641 } 642 643 // Save the visibility level 644 $visibility_level = ! empty( $_POST['field_' . $field_id . '_visibility'] ) ? $_POST['field_' . $field_id . '_visibility'] : 'public'; 645 xprofile_set_field_visibility_level( $field_id, bp_displayed_user_id(), $visibility_level ); 646 } 647 648 do_action( 'xprofile_updated_profile', $user_id, $posted_field_ids, $errors ); 649 650 // Set the feedback messages 651 if ( ! empty( $errors ) ) { 652 $redirect_to = add_query_arg( 'error', '3', $redirect_to ); 653 } else { 654 $redirect_to = add_query_arg( 'updated', '1', $redirect_to ); 655 } 656 657 bp_core_redirect( $redirect_to ); 658 } 659 } 660 661 } 662 663 /** 664 * Renders the xprofile metabox for user's profile screen. 665 * 666 * @access public 667 * @since BuddyPress (2.0.0) 668 * 669 * @param WP_User $user The WP_User object for the user's profile to edit 670 */ 671 public function user_admin_profile_metaboxes( $user = null, $args = array() ) { 672 673 if ( empty( $user->ID ) ) { 674 return; 675 } 676 677 $r = bp_parse_args( $args['args'], array( 678 'profile_group_id' => 0, 679 'user_id' => $user->ID 680 ), 'bp_xprofile_user_admin_profile_loop_args' ); 681 682 // We really need these args 683 if ( empty( $r['profile_group_id'] ) || empty( $r['user_id'] ) ) { 684 return; 685 } 686 687 if ( bp_has_profile( $r ) ) : 688 689 while ( bp_profile_groups() ) : bp_the_profile_group(); ?> 690 691 <p class="description"><?php bp_the_profile_group_description(); ?></p> 692 693 <table class="form-table"> 694 <tbody> 695 696 <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> 697 698 <tr> 699 700 <?php if ( 'textbox' === bp_get_the_profile_field_type() ) : ?> 701 702 <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> 703 <td> 704 <input type="text" name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" value="<?php bp_the_profile_field_edit_value(); ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>/> 705 <span class="description"><?php bp_the_profile_field_description(); ?></span> 706 </td> 707 708 <?php endif; ?> 709 710 <?php if ( 'textarea' === bp_get_the_profile_field_type() ) : ?> 711 712 <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> 713 <td> 714 <textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>><?php bp_the_profile_field_edit_value(); ?></textarea> 715 <p class="description"><?php bp_the_profile_field_description(); ?></p> 716 </td> 717 718 <?php endif; ?> 719 720 <?php if ( 'selectbox' === bp_get_the_profile_field_type() ) : ?> 721 722 <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> 723 <td> 724 <select name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> 725 <?php bp_the_profile_field_options(); ?> 726 </select> 727 <span class="description"><?php bp_the_profile_field_description(); ?></span> 728 </td> 729 730 <?php endif; ?> 731 732 <?php if ( 'multiselectbox' === bp_get_the_profile_field_type() ) : ?> 733 734 <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> 735 <td> 736 <select name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" multiple="multiple" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> 737 738 <?php bp_the_profile_field_options(); ?> 739 740 </select> 741 742 743 <?php if ( !bp_get_the_profile_field_is_required() ) : ?> 744 745 <p><a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name(); ?>' );"><?php _e( 'Clear', 'buddypress' ); ?></a></p> 746 747 <?php endif; ?> 748 <p class="description"><?php bp_the_profile_field_description(); ?></p> 749 </td> 750 751 <?php endif; ?> 752 753 <?php if ( 'radio' === bp_get_the_profile_field_type() ) : ?> 754 755 <th> 756 <span class="label"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></span> 757 </th> 758 <td> 759 <fieldset> 760 <legend class="screen-reader-text"><span><?php bp_the_profile_field_name(); ?></span></legend> 761 <?php bp_the_profile_field_options(); ?> 762 </fieldset> 763 764 <?php if ( !bp_get_the_profile_field_is_required() ) : ?> 765 766 <p><a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name(); ?>' );"><?php _e( 'Clear', 'buddypress' ); ?></a></p> 767 768 <?php endif; ?> 769 <p class="description"><?php bp_the_profile_field_description(); ?></p> 770 </td> 771 772 <?php endif; ?> 773 774 <?php if ( 'checkbox' === bp_get_the_profile_field_type() ) : ?> 775 776 <th> 777 <span class="label"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></span> 778 </th> 779 <td> 780 <?php bp_the_profile_field_options(); ?> 781 <p class="description"><?php bp_the_profile_field_description(); ?></p> 782 </td> 783 784 <?php endif; ?> 785 786 <?php if ( 'datebox' === bp_get_the_profile_field_type() ) : ?> 787 788 <th> 789 <label for="<?php bp_the_profile_field_input_name(); ?>_day"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label> 790 </th> 791 <td> 792 <select name="<?php bp_the_profile_field_input_name(); ?>_day" id="<?php bp_the_profile_field_input_name(); ?>_day" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> 793 794 <?php bp_the_profile_field_options( 'type=day' ); ?> 795 796 </select> 797 798 <select name="<?php bp_the_profile_field_input_name(); ?>_month" id="<?php bp_the_profile_field_input_name(); ?>_month" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> 799 800 <?php bp_the_profile_field_options( 'type=month' ); ?> 801 802 </select> 803 804 <select name="<?php bp_the_profile_field_input_name(); ?>_year" id="<?php bp_the_profile_field_input_name(); ?>_year" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> 805 806 <?php bp_the_profile_field_options( 'type=year' ); ?> 807 808 </select> 809 <p class="description"><?php bp_the_profile_field_description(); ?></p> 810 </td> 811 812 <?php endif; ?> 813 814 </tr> 815 816 <tr class="admin-field-visibility-tr"> 817 <td class="admin-field-visibility-td"> </td> 818 <td class="admin-field-visibility-td"> 819 820 <?php do_action( 'bp_custom_profile_edit_fields_pre_visibility' ); ?> 821 822 <?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?> 823 <p class="description field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>"> 824 <?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> <a href="#" class="visibility-toggle-link"><?php _e( 'Change', 'buddypress' ); ?></a> 825 </p> 826 827 <div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id() ?>"> 828 <fieldset> 829 <legend><?php _e( 'Who can see this field?', 'buddypress' ) ?></legend> 830 831 <?php bp_profile_visibility_radio_buttons() ?> 832 833 </fieldset> 834 <a class="field-visibility-settings-close" href="#"><?php _e( 'Close', 'buddypress' ) ?></a> 835 </div> 836 <?php else : ?> 837 <div class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>"> 838 <?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> 839 </div> 840 <?php endif ?> 841 842 </td> 843 </tr> 844 845 <?php endwhile; ?> 846 </tbody> 847 848 </table> 849 <input type="hidden" name="field_ids[]" id="field_ids_<?php bp_the_profile_group_slug(); ?>" value="<?php bp_the_profile_group_field_ids(); ?>" /> 850 <?php endwhile; 851 endif; 852 } 853 854 /** 855 * Renders the fallback metabox in case a user has been marked as a spammer. 856 * 857 * @access public 858 * @since BuddyPress (2.0.0) 859 * 860 * @param WP_User $user The WP_User object for the user's profile to edit 861 */ 862 public function user_admin_spammer_metabox( $user = null ) { 863 ?> 864 <p><?php printf( __( '%s has been marked as a spammer, this user's BuddyPress datas were removed', 'buddypress' ), bp_core_get_user_displayname( $user->ID ) ) ;?></p> 865 <?php 866 } 867 868 /** 869 * Renders the Avatar metabox to moderate inappropriate images. 870 * 871 * @access public 872 * @since BuddyPress (2.0.0) 873 * 874 * @param WP_User $user The WP_User object for the user's profile to edit 875 */ 876 public function user_admin_avatar_metabox( $user = null ) { 877 878 if ( empty( $user->ID ) ) { 879 return; 880 } 881 882 $args = array( 883 'item_id' => $user->ID, 884 'object' => 'user', 885 'type' => 'full', 886 'title' => $user->display_name 887 ); 888 889 ?> 890 891 <div class="avatar"> 892 893 <?php echo bp_core_fetch_avatar( $args ); ?> 894 895 <?php if ( bp_get_user_has_avatar( $user->ID ) ) : 896 897 $query_args = array( 898 'user_id' => $user->ID, 899 'action' => 'delete_avatar' 900 ); 901 902 if ( ! empty( $_REQUEST['wp_http_referer'] ) ) 903 $query_args['wp_http_referer'] = urlencode( wp_unslash( $_REQUEST['wp_http_referer'] ) ); 904 905 $community_url = add_query_arg( $query_args, buddypress()->members->admin->edit_profile_url ); 906 $delete_link = wp_nonce_url( $community_url, 'delete_avatar' ); ?> 907 908 <a href="<?php echo esc_url( $delete_link ); ?>" title="<?php _e( 'Delete Avatar', 'buddypress' ); ?>"><span class="dashicons dashicons dashicons-trash"></span> <?php _e( 'Delete Avatar', 'buddypress' ); ?></a></li> 909 910 <?php endif; ?> 911 912 </div> 913 <?php 914 } 915 916 } 917 918 endif; // class_exists check 919 920 /** 921 * Setup xProfile User Admin. 922 * 923 * @since BuddyPress (2.0.0) 924 * 925 * @uses buddypress() to get BuddyPress main instance 926 */ 927 function xprofile_user_admin() { 928 buddypress()->profile->admin = new BP_XProfile_User_Admin(); 929 } 930 931 // Load the xprofile user admin 932 if ( is_admin() ) { 933 add_action( 'bp_init', 'xprofile_user_admin', 11 ); 934 } -
bp-xprofile/bp-xprofile-filters.php
247 247 function bp_xprofile_filter_user_query_populate_extras( BP_User_Query $user_query, $user_ids_sql ) { 248 248 global $bp, $wpdb; 249 249 250 if ( bp_is_active( 'xprofile' ) ) {251 $fullname_field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", bp_xprofile_fullname_field_name() ) );252 $user_id_names = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, value as fullname FROM {$bp->profile->table_name_data} WHERE user_id IN ({$user_ids_sql}) AND field_id = %d", $fullname_field_id ) );250 if ( ! bp_is_active( 'xprofile' ) ) { 251 return; 252 } 253 253 254 // Loop through names and override each user's fullname 255 foreach ( $user_id_names as $user ) { 256 if ( isset( $user_query->results[ $user->user_id ] ) ) { 257 $user_query->results[ $user->user_id ]->fullname = $user->fullname; 258 } 254 $fullname_field_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", bp_xprofile_fullname_field_name() ) ); 255 $user_id_names = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, value as fullname FROM {$bp->profile->table_name_data} WHERE user_id IN ({$user_ids_sql}) AND field_id = %d", $fullname_field_id ) ); 256 257 // Loop through names and override each user's fullname 258 foreach ( $user_id_names as $user ) { 259 if ( isset( $user_query->results[ $user->user_id ] ) ) { 260 $user_query->results[ $user->user_id ]->fullname = $user->fullname; 259 261 } 260 262 } 261 263 } 262 264 add_filter( 'bp_user_query_populate_extras', 'bp_xprofile_filter_user_query_populate_extras', 2, 2 ); 265 266 /** 267 * Filter radio profile fields output in administration screens 268 * 269 * @since BuddyPress (2.0.0) 270 * 271 * @param string $output 272 * @param object $option 273 * @param integer $field_id 274 * @param boolean $selected 275 * @uses is_admin() to check if in an administration screen 276 * @return string the output for administration screens 277 */ 278 function bp_xprofile_admin_format_radio( $output = '', $option = null, $field_id = 0, $selected = false ) { 279 if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { 280 $output = '<label><input' . $selected . ' type="radio" name="field_' . absint( $field_id ) . '" id="option_' . esc_attr( $option->id ) . '" value="' . esc_attr( stripslashes( $option->name ) ) . '"> ' . esc_attr( stripslashes( $option->name ) ) . '</label><br/>'; 281 } 282 283 return $output; 284 } 285 add_filter( 'bp_get_the_profile_field_options_radio', 'bp_xprofile_admin_format_radio', 10, 4 ); 286 287 /** 288 * Filter checkbox profile fields output in administration screens 289 * 290 * @since BuddyPress (2.0.0) 291 * 292 * @param string $output 293 * @param object $option 294 * @param integer $field_id 295 * @param boolean $selected 296 * @param integer $k 297 * @uses is_admin() to check if in an administration screen 298 * @return string the output for administration screens 299 */ 300 function bp_xprofile_admin_format_checkbox( $output= '', $option = null, $field_id = 0, $selected = false, $k = 0 ) { 301 if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { 302 $output = '<label><input' . $selected . ' type="checkbox" name="field_' . absint( $field_id ) . '[]" id="field_' . esc_attr( $option->id ) . '_' . absint( $k ) . '" value="' . esc_attr( stripslashes( $option->name ) ) . '"> ' . esc_attr( stripslashes( $option->name ) ) . '</label><br/>'; 303 } 304 305 return $output; 306 } 307 add_filter( 'bp_get_the_profile_field_options_checkbox', 'bp_xprofile_admin_format_checkbox', 10, 5 ); -
bp-xprofile/bp-xprofile-template.php
51 51 function next_group() { 52 52 $this->current_group++; 53 53 54 $this->group = $this->groups[$this->current_group]; 55 $this->group->fields = apply_filters( 'xprofile_group_fields', $this->group->fields, $this->group->id ); 56 $this->field_count = count( $this->group->fields ); 54 $this->group = $this->groups[$this->current_group]; 55 $this->field_count = 0; 56 57 if( ! empty( $this->group->fields ) ) { 58 $this->group->fields = apply_filters( 'xprofile_group_fields', $this->group->fields, $this->group->id ); 59 $this->field_count = count( $this->group->fields ); 60 } 57 61 58 62 return $this->group; 59 63 }