78 |
78 |
79 /** |
79 /** |
80 * All capabilities the user has, including individual and role based. |
80 * All capabilities the user has, including individual and role based. |
81 * |
81 * |
82 * @since 2.0.0 |
82 * @since 2.0.0 |
83 * @var array |
83 * @var bool[] Array of key/value pairs where keys represent a capability name and boolean values |
|
84 * represent whether the user has that capability. |
84 */ |
85 */ |
85 public $allcaps = array(); |
86 public $allcaps = array(); |
86 |
87 |
87 /** |
88 /** |
88 * The filter context applied to user data fields. |
89 * The filter context applied to user data fields. |
111 * Constructor. |
111 * Constructor. |
112 * |
112 * |
113 * Retrieves the userdata and passes it to WP_User::init(). |
113 * Retrieves the userdata and passes it to WP_User::init(). |
114 * |
114 * |
115 * @since 2.0.0 |
115 * @since 2.0.0 |
116 * |
|
117 * @global wpdb $wpdb WordPress database abstraction object. |
|
118 * |
116 * |
119 * @param int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB. |
117 * @param int|string|stdClass|WP_User $id User's ID, a WP_User object, or a user object from the DB. |
120 * @param string $name Optional. User's username |
118 * @param string $name Optional. User's username |
121 * @param int $site_id Optional Site ID, defaults to current site. |
119 * @param int $site_id Optional Site ID, defaults to current site. |
122 */ |
120 */ |
123 public function __construct( $id = 0, $name = '', $site_id = '' ) { |
121 public function __construct( $id = 0, $name = '', $site_id = '' ) { |
124 if ( ! isset( self::$back_compat_keys ) ) { |
122 if ( ! isset( self::$back_compat_keys ) ) { |
125 $prefix = $GLOBALS['wpdb']->prefix; |
123 $prefix = $GLOBALS['wpdb']->prefix; |
126 self::$back_compat_keys = array( |
124 self::$back_compat_keys = array( |
127 'user_firstname' => 'first_name', |
125 'user_firstname' => 'first_name', |
128 'user_lastname' => 'last_name', |
126 'user_lastname' => 'last_name', |
129 'user_description' => 'description', |
127 'user_description' => 'description', |
130 'user_level' => $prefix . 'user_level', |
128 'user_level' => $prefix . 'user_level', |
131 $prefix . 'usersettings' => $prefix . 'user-settings', |
129 $prefix . 'usersettings' => $prefix . 'user-settings', |
132 $prefix . 'usersettingstime' => $prefix . 'user-settings-time', |
130 $prefix . 'usersettingstime' => $prefix . 'user-settings-time', |
133 ); |
131 ); |
134 } |
132 } |
135 |
133 |
136 if ( $id instanceof WP_User ) { |
134 if ( $id instanceof WP_User ) { |
167 * @param object $data User DB row object. |
165 * @param object $data User DB row object. |
168 * @param int $site_id Optional. The site ID to initialize for. |
166 * @param int $site_id Optional. The site ID to initialize for. |
169 */ |
167 */ |
170 public function init( $data, $site_id = '' ) { |
168 public function init( $data, $site_id = '' ) { |
171 $this->data = $data; |
169 $this->data = $data; |
172 $this->ID = (int) $data->ID; |
170 $this->ID = (int) $data->ID; |
173 |
171 |
174 $this->for_site( $site_id ); |
172 $this->for_site( $site_id ); |
175 } |
173 } |
176 |
174 |
177 /** |
175 /** |
178 * Return only the main user fields |
176 * Return only the main user fields |
179 * |
177 * |
180 * @since 3.3.0 |
178 * @since 3.3.0 |
181 * @since 4.4.0 Added 'ID' as an alias of 'id' for the `$field` parameter. |
179 * @since 4.4.0 Added 'ID' as an alias of 'id' for the `$field` parameter. |
182 * |
|
183 * @static |
|
184 * |
180 * |
185 * @global wpdb $wpdb WordPress database abstraction object. |
181 * @global wpdb $wpdb WordPress database abstraction object. |
186 * |
182 * |
187 * @param string $field The field to query against: 'id', 'ID', 'slug', 'email' or 'login'. |
183 * @param string $field The field to query against: 'id', 'ID', 'slug', 'email' or 'login'. |
188 * @param string|int $value The field value |
184 * @param string|int $value The field value |
197 } |
193 } |
198 |
194 |
199 if ( 'id' == $field ) { |
195 if ( 'id' == $field ) { |
200 // Make sure the value is numeric to avoid casting objects, for example, |
196 // Make sure the value is numeric to avoid casting objects, for example, |
201 // to int 1. |
197 // to int 1. |
202 if ( ! is_numeric( $value ) ) |
198 if ( ! is_numeric( $value ) ) { |
203 return false; |
199 return false; |
|
200 } |
204 $value = intval( $value ); |
201 $value = intval( $value ); |
205 if ( $value < 1 ) |
202 if ( $value < 1 ) { |
206 return false; |
203 return false; |
|
204 } |
207 } else { |
205 } else { |
208 $value = trim( $value ); |
206 $value = trim( $value ); |
209 } |
207 } |
210 |
208 |
211 if ( !$value ) |
209 if ( ! $value ) { |
212 return false; |
210 return false; |
|
211 } |
213 |
212 |
214 switch ( $field ) { |
213 switch ( $field ) { |
215 case 'id': |
214 case 'id': |
216 $user_id = $value; |
215 $user_id = $value; |
217 $db_field = 'ID'; |
216 $db_field = 'ID'; |
218 break; |
217 break; |
219 case 'slug': |
218 case 'slug': |
220 $user_id = wp_cache_get($value, 'userslugs'); |
219 $user_id = wp_cache_get( $value, 'userslugs' ); |
221 $db_field = 'user_nicename'; |
220 $db_field = 'user_nicename'; |
222 break; |
221 break; |
223 case 'email': |
222 case 'email': |
224 $user_id = wp_cache_get($value, 'useremail'); |
223 $user_id = wp_cache_get( $value, 'useremail' ); |
225 $db_field = 'user_email'; |
224 $db_field = 'user_email'; |
226 break; |
225 break; |
227 case 'login': |
226 case 'login': |
228 $value = sanitize_user( $value ); |
227 $value = sanitize_user( $value ); |
229 $user_id = wp_cache_get($value, 'userlogins'); |
228 $user_id = wp_cache_get( $value, 'userlogins' ); |
230 $db_field = 'user_login'; |
229 $db_field = 'user_login'; |
231 break; |
230 break; |
232 default: |
231 default: |
233 return false; |
232 return false; |
234 } |
233 } |
235 |
234 |
236 if ( false !== $user_id ) { |
235 if ( false !== $user_id ) { |
237 if ( $user = wp_cache_get( $user_id, 'users' ) ) |
236 if ( $user = wp_cache_get( $user_id, 'users' ) ) { |
238 return $user; |
237 return $user; |
239 } |
238 } |
240 |
239 } |
241 if ( !$user = $wpdb->get_row( $wpdb->prepare( |
240 |
242 "SELECT * FROM $wpdb->users WHERE $db_field = %s", $value |
241 if ( ! $user = $wpdb->get_row( |
243 ) ) ) |
242 $wpdb->prepare( |
|
243 "SELECT * FROM $wpdb->users WHERE $db_field = %s LIMIT 1", |
|
244 $value |
|
245 ) |
|
246 ) ) { |
244 return false; |
247 return false; |
|
248 } |
245 |
249 |
246 update_user_caches( $user ); |
250 update_user_caches( $user ); |
247 |
251 |
248 return $user; |
252 return $user; |
249 } |
253 } |
256 * @param string $key User meta key to check if set. |
260 * @param string $key User meta key to check if set. |
257 * @return bool Whether the given user meta key is set. |
261 * @return bool Whether the given user meta key is set. |
258 */ |
262 */ |
259 public function __isset( $key ) { |
263 public function __isset( $key ) { |
260 if ( 'id' == $key ) { |
264 if ( 'id' == $key ) { |
261 _deprecated_argument( 'WP_User->id', '2.1.0', |
265 _deprecated_argument( |
|
266 'WP_User->id', |
|
267 '2.1.0', |
262 sprintf( |
268 sprintf( |
263 /* translators: %s: WP_User->ID */ |
269 /* translators: %s: WP_User->ID */ |
264 __( 'Use %s instead.' ), |
270 __( 'Use %s instead.' ), |
265 '<code>WP_User->ID</code>' |
271 '<code>WP_User->ID</code>' |
266 ) |
272 ) |
267 ); |
273 ); |
268 $key = 'ID'; |
274 $key = 'ID'; |
269 } |
275 } |
270 |
276 |
271 if ( isset( $this->data->$key ) ) |
277 if ( isset( $this->data->$key ) ) { |
272 return true; |
278 return true; |
273 |
279 } |
274 if ( isset( self::$back_compat_keys[ $key ] ) ) |
280 |
|
281 if ( isset( self::$back_compat_keys[ $key ] ) ) { |
275 $key = self::$back_compat_keys[ $key ]; |
282 $key = self::$back_compat_keys[ $key ]; |
|
283 } |
276 |
284 |
277 return metadata_exists( 'user', $this->ID, $key ); |
285 return metadata_exists( 'user', $this->ID, $key ); |
278 } |
286 } |
279 |
287 |
280 /** |
288 /** |
285 * @param string $key User meta key to retrieve. |
293 * @param string $key User meta key to retrieve. |
286 * @return mixed Value of the given user meta key (if set). If `$key` is 'id', the user ID. |
294 * @return mixed Value of the given user meta key (if set). If `$key` is 'id', the user ID. |
287 */ |
295 */ |
288 public function __get( $key ) { |
296 public function __get( $key ) { |
289 if ( 'id' == $key ) { |
297 if ( 'id' == $key ) { |
290 _deprecated_argument( 'WP_User->id', '2.1.0', |
298 _deprecated_argument( |
|
299 'WP_User->id', |
|
300 '2.1.0', |
291 sprintf( |
301 sprintf( |
292 /* translators: %s: WP_User->ID */ |
302 /* translators: %s: WP_User->ID */ |
293 __( 'Use %s instead.' ), |
303 __( 'Use %s instead.' ), |
294 '<code>WP_User->ID</code>' |
304 '<code>WP_User->ID</code>' |
295 ) |
305 ) |
298 } |
308 } |
299 |
309 |
300 if ( isset( $this->data->$key ) ) { |
310 if ( isset( $this->data->$key ) ) { |
301 $value = $this->data->$key; |
311 $value = $this->data->$key; |
302 } else { |
312 } else { |
303 if ( isset( self::$back_compat_keys[ $key ] ) ) |
313 if ( isset( self::$back_compat_keys[ $key ] ) ) { |
304 $key = self::$back_compat_keys[ $key ]; |
314 $key = self::$back_compat_keys[ $key ]; |
|
315 } |
305 $value = get_user_meta( $this->ID, $key, true ); |
316 $value = get_user_meta( $this->ID, $key, true ); |
306 } |
317 } |
307 |
318 |
308 if ( $this->filter ) { |
319 if ( $this->filter ) { |
309 $value = sanitize_user_field( $key, $value, $this->ID, $this->filter ); |
320 $value = sanitize_user_field( $key, $value, $this->ID, $this->filter ); |
323 * @param string $key User meta key. |
334 * @param string $key User meta key. |
324 * @param mixed $value User meta value. |
335 * @param mixed $value User meta value. |
325 */ |
336 */ |
326 public function __set( $key, $value ) { |
337 public function __set( $key, $value ) { |
327 if ( 'id' == $key ) { |
338 if ( 'id' == $key ) { |
328 _deprecated_argument( 'WP_User->id', '2.1.0', |
339 _deprecated_argument( |
|
340 'WP_User->id', |
|
341 '2.1.0', |
329 sprintf( |
342 sprintf( |
330 /* translators: %s: WP_User->ID */ |
343 /* translators: %s: WP_User->ID */ |
331 __( 'Use %s instead.' ), |
344 __( 'Use %s instead.' ), |
332 '<code>WP_User->ID</code>' |
345 '<code>WP_User->ID</code>' |
333 ) |
346 ) |
346 * |
359 * |
347 * @param string $key User meta key to unset. |
360 * @param string $key User meta key to unset. |
348 */ |
361 */ |
349 public function __unset( $key ) { |
362 public function __unset( $key ) { |
350 if ( 'id' == $key ) { |
363 if ( 'id' == $key ) { |
351 _deprecated_argument( 'WP_User->id', '2.1.0', |
364 _deprecated_argument( |
|
365 'WP_User->id', |
|
366 '2.1.0', |
352 sprintf( |
367 sprintf( |
353 /* translators: %s: WP_User->ID */ |
368 /* translators: %s: WP_User->ID */ |
354 __( 'Use %s instead.' ), |
369 __( 'Use %s instead.' ), |
355 '<code>WP_User->ID</code>' |
370 '<code>WP_User->ID</code>' |
356 ) |
371 ) |
419 /** |
434 /** |
420 * Makes private/protected methods readable for backward compatibility. |
435 * Makes private/protected methods readable for backward compatibility. |
421 * |
436 * |
422 * @since 4.3.0 |
437 * @since 4.3.0 |
423 * |
438 * |
424 * @param callable $name Method to call. |
439 * @param string $name Method to call. |
425 * @param array $arguments Arguments to pass when calling. |
440 * @param array $arguments Arguments to pass when calling. |
426 * @return mixed|false Return value of the callback, false otherwise. |
441 * @return mixed|false Return value of the callback, false otherwise. |
427 */ |
442 */ |
428 public function __call( $name, $arguments ) { |
443 public function __call( $name, $arguments ) { |
429 if ( '_init_caps' === $name ) { |
444 if ( '_init_caps' === $name ) { |
462 |
477 |
463 $this->get_role_caps(); |
478 $this->get_role_caps(); |
464 } |
479 } |
465 |
480 |
466 /** |
481 /** |
467 * Retrieve all of the role capabilities and merge with individual capabilities. |
482 * Retrieves all of the capabilities of the roles of the user, and merges them with individual user capabilities. |
468 * |
483 * |
469 * All of the capabilities of the roles the user belongs to are merged with |
484 * All of the capabilities of the roles of the user are merged with the user's individual capabilities. This means |
470 * the users individual roles. This also means that the user can be denied |
485 * that the user can be denied specific capabilities that their role might have, but the user is specifically denied. |
471 * specific roles that their role might have, but the specific user isn't |
486 * |
472 * granted permission to. |
487 * @since 2.0.0 |
473 * |
488 * |
474 * @since 2.0.0 |
489 * @return bool[] Array of key/value pairs where keys represent a capability name and boolean values |
475 * |
490 * represent whether the user has that capability. |
476 * @return array List of all capabilities for the user. |
|
477 */ |
491 */ |
478 public function get_role_caps() { |
492 public function get_role_caps() { |
479 $switch_site = false; |
493 $switch_site = false; |
480 if ( is_multisite() && $this->site_id != get_current_blog_id() ) { |
494 if ( is_multisite() && $this->site_id != get_current_blog_id() ) { |
481 $switch_site = true; |
495 $switch_site = true; |
483 switch_to_blog( $this->site_id ); |
497 switch_to_blog( $this->site_id ); |
484 } |
498 } |
485 |
499 |
486 $wp_roles = wp_roles(); |
500 $wp_roles = wp_roles(); |
487 |
501 |
488 //Filter out caps that are not role names and assign to $this->roles |
502 // Filter out caps that are not role names and assign to $this->roles. |
489 if ( is_array( $this->caps ) ) |
503 if ( is_array( $this->caps ) ) { |
490 $this->roles = array_filter( array_keys( $this->caps ), array( $wp_roles, 'is_role' ) ); |
504 $this->roles = array_filter( array_keys( $this->caps ), array( $wp_roles, 'is_role' ) ); |
491 |
505 } |
492 //Build $allcaps from role caps, overlay user's $caps |
506 |
|
507 // Build $allcaps from role caps, overlay user's $caps. |
493 $this->allcaps = array(); |
508 $this->allcaps = array(); |
494 foreach ( (array) $this->roles as $role ) { |
509 foreach ( (array) $this->roles as $role ) { |
495 $the_role = $wp_roles->get_role( $role ); |
510 $the_role = $wp_roles->get_role( $role ); |
496 $this->allcaps = array_merge( (array) $this->allcaps, (array) $the_role->capabilities ); |
511 $this->allcaps = array_merge( (array) $this->allcaps, (array) $the_role->capabilities ); |
497 } |
512 } |
498 $this->allcaps = array_merge( (array) $this->allcaps, (array) $this->caps ); |
513 $this->allcaps = array_merge( (array) $this->allcaps, (array) $this->caps ); |
499 |
514 |
500 if ( $switch_site ) { |
515 if ( $switch_site ) { |
516 public function add_role( $role ) { |
531 public function add_role( $role ) { |
517 if ( empty( $role ) ) { |
532 if ( empty( $role ) ) { |
518 return; |
533 return; |
519 } |
534 } |
520 |
535 |
521 $this->caps[$role] = true; |
536 $this->caps[ $role ] = true; |
522 update_user_meta( $this->ID, $this->cap_key, $this->caps ); |
537 update_user_meta( $this->ID, $this->cap_key, $this->caps ); |
523 $this->get_role_caps(); |
538 $this->get_role_caps(); |
524 $this->update_user_level_from_caps(); |
539 $this->update_user_level_from_caps(); |
525 |
540 |
526 /** |
541 /** |
540 * @since 2.0.0 |
555 * @since 2.0.0 |
541 * |
556 * |
542 * @param string $role Role name. |
557 * @param string $role Role name. |
543 */ |
558 */ |
544 public function remove_role( $role ) { |
559 public function remove_role( $role ) { |
545 if ( !in_array($role, $this->roles) ) |
560 if ( ! in_array( $role, $this->roles ) ) { |
546 return; |
561 return; |
547 unset( $this->caps[$role] ); |
562 } |
|
563 unset( $this->caps[ $role ] ); |
548 update_user_meta( $this->ID, $this->cap_key, $this->caps ); |
564 update_user_meta( $this->ID, $this->cap_key, $this->caps ); |
549 $this->get_role_caps(); |
565 $this->get_role_caps(); |
550 $this->update_user_level_from_caps(); |
566 $this->update_user_level_from_caps(); |
551 |
567 |
552 /** |
568 /** |
570 * @since 2.0.0 |
586 * @since 2.0.0 |
571 * |
587 * |
572 * @param string $role Role name. |
588 * @param string $role Role name. |
573 */ |
589 */ |
574 public function set_role( $role ) { |
590 public function set_role( $role ) { |
575 if ( 1 == count( $this->roles ) && $role == current( $this->roles ) ) |
591 if ( 1 == count( $this->roles ) && $role == current( $this->roles ) ) { |
576 return; |
592 return; |
577 |
593 } |
578 foreach ( (array) $this->roles as $oldrole ) |
594 |
579 unset( $this->caps[$oldrole] ); |
595 foreach ( (array) $this->roles as $oldrole ) { |
|
596 unset( $this->caps[ $oldrole ] ); |
|
597 } |
580 |
598 |
581 $old_roles = $this->roles; |
599 $old_roles = $this->roles; |
582 if ( !empty( $role ) ) { |
600 if ( ! empty( $role ) ) { |
583 $this->caps[$role] = true; |
601 $this->caps[ $role ] = true; |
584 $this->roles = array( $role => true ); |
602 $this->roles = array( $role => true ); |
585 } else { |
603 } else { |
586 $this->roles = false; |
604 $this->roles = false; |
587 } |
605 } |
588 update_user_meta( $this->ID, $this->cap_key, $this->caps ); |
606 update_user_meta( $this->ID, $this->cap_key, $this->caps ); |
589 $this->get_role_caps(); |
607 $this->get_role_caps(); |
593 * Fires after the user's role has changed. |
611 * Fires after the user's role has changed. |
594 * |
612 * |
595 * @since 2.9.0 |
613 * @since 2.9.0 |
596 * @since 3.6.0 Added $old_roles to include an array of the user's previous roles. |
614 * @since 3.6.0 Added $old_roles to include an array of the user's previous roles. |
597 * |
615 * |
598 * @param int $user_id The user ID. |
616 * @param int $user_id The user ID. |
599 * @param string $role The new role. |
617 * @param string $role The new role. |
600 * @param array $old_roles An array of the user's previous roles. |
618 * @param string[] $old_roles An array of the user's previous roles. |
601 */ |
619 */ |
602 do_action( 'set_user_role', $this->ID, $role, $old_roles ); |
620 do_action( 'set_user_role', $this->ID, $role, $old_roles ); |
603 } |
621 } |
604 |
622 |
605 /** |
623 /** |
653 * |
671 * |
654 * @param string $cap Capability name. |
672 * @param string $cap Capability name. |
655 * @param bool $grant Whether to grant capability to user. |
673 * @param bool $grant Whether to grant capability to user. |
656 */ |
674 */ |
657 public function add_cap( $cap, $grant = true ) { |
675 public function add_cap( $cap, $grant = true ) { |
658 $this->caps[$cap] = $grant; |
676 $this->caps[ $cap ] = $grant; |
659 update_user_meta( $this->ID, $this->cap_key, $this->caps ); |
677 update_user_meta( $this->ID, $this->cap_key, $this->caps ); |
660 $this->get_role_caps(); |
678 $this->get_role_caps(); |
661 $this->update_user_level_from_caps(); |
679 $this->update_user_level_from_caps(); |
662 } |
680 } |
663 |
681 |
721 $args = array_merge( array( $cap, $this->ID ), $args ); |
739 $args = array_merge( array( $cap, $this->ID ), $args ); |
722 $caps = call_user_func_array( 'map_meta_cap', $args ); |
740 $caps = call_user_func_array( 'map_meta_cap', $args ); |
723 |
741 |
724 // Multisite super admin has all caps by definition, Unless specifically denied. |
742 // Multisite super admin has all caps by definition, Unless specifically denied. |
725 if ( is_multisite() && is_super_admin( $this->ID ) ) { |
743 if ( is_multisite() && is_super_admin( $this->ID ) ) { |
726 if ( in_array('do_not_allow', $caps) ) |
744 if ( in_array( 'do_not_allow', $caps ) ) { |
727 return false; |
745 return false; |
|
746 } |
728 return true; |
747 return true; |
729 } |
748 } |
730 |
749 |
731 /** |
750 /** |
732 * Dynamically filter a user's capabilities. |
751 * Dynamically filter a user's capabilities. |
733 * |
752 * |
734 * @since 2.0.0 |
753 * @since 2.0.0 |
735 * @since 3.7.0 Added the user object. |
754 * @since 3.7.0 Added the `$user` parameter. |
736 * |
755 * |
737 * @param array $allcaps An array of all the user's capabilities. |
756 * @param bool[] $allcaps Array of key/value pairs where keys represent a capability name and boolean values |
738 * @param array $caps Actual capabilities for meta capability. |
757 * represent whether the user has that capability. |
739 * @param array $args Optional parameters passed to has_cap(), typically object ID. |
758 * @param string[] $caps Required primitive capabilities for the requested capability. |
740 * @param WP_User $user The user object. |
759 * @param array $args { |
|
760 * Arguments that accompany the requested capability check. |
|
761 * |
|
762 * @type string $0 Requested capability. |
|
763 * @type int $1 Concerned user ID. |
|
764 * @type mixed ...$2 Optional second and further parameters, typically object ID. |
|
765 * } |
|
766 * @param WP_User $user The user object. |
741 */ |
767 */ |
742 $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args, $this ); |
768 $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args, $this ); |
743 |
769 |
744 // Everyone is allowed to exist. |
770 // Everyone is allowed to exist. |
745 $capabilities['exist'] = true; |
771 $capabilities['exist'] = true; |
747 // Nobody is allowed to do things they are not allowed to do. |
773 // Nobody is allowed to do things they are not allowed to do. |
748 unset( $capabilities['do_not_allow'] ); |
774 unset( $capabilities['do_not_allow'] ); |
749 |
775 |
750 // Must have ALL requested caps. |
776 // Must have ALL requested caps. |
751 foreach ( (array) $caps as $cap ) { |
777 foreach ( (array) $caps as $cap ) { |
752 if ( empty( $capabilities[ $cap ] ) ) |
778 if ( empty( $capabilities[ $cap ] ) ) { |
753 return false; |
779 return false; |
|
780 } |
754 } |
781 } |
755 |
782 |
756 return true; |
783 return true; |
757 } |
784 } |
758 |
785 |
773 /** |
800 /** |
774 * Set the site to operate on. Defaults to the current site. |
801 * Set the site to operate on. Defaults to the current site. |
775 * |
802 * |
776 * @since 3.0.0 |
803 * @since 3.0.0 |
777 * @deprecated 4.9.0 Use WP_User::for_site() |
804 * @deprecated 4.9.0 Use WP_User::for_site() |
778 * |
|
779 * @global wpdb $wpdb WordPress database abstraction object. |
|
780 * |
805 * |
781 * @param int $blog_id Optional. Site ID, defaults to current site. |
806 * @param int $blog_id Optional. Site ID, defaults to current site. |
782 */ |
807 */ |
783 public function for_blog( $blog_id = '' ) { |
808 public function for_blog( $blog_id = '' ) { |
784 _deprecated_function( __METHOD__, '4.9.0', 'WP_User::for_site()' ); |
809 _deprecated_function( __METHOD__, '4.9.0', 'WP_User::for_site()' ); |