Opened 7 weeks ago
Last modified 7 weeks ago
#64131 new feature request
A new function to test if a thing is an instance of the WP_User class
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 6.9 |
| Component: | Users | Keywords: | |
| Focuses: | Cc: |
Description
<?php function is_wp_user( $thing ) { return ( $thing instanceof WP_User ); }
Change History (2)
#2
in reply to:
↑ 1
@
7 weeks ago
A current function,is_wp_error, does something similar regarding the WP_Error class: https://developer.wordpress.org/reference/functions/is_wp_error/ .When developing my plugin, Describr (https://wordpress.org/plugins/describr/), I used namespaces, and it became tedious doing $thing instanceof \WP_User often to break out of the namespaces. Replying to swissspidy:
Hi there and welcome to WordPress Trac!
What would be the benefit of adding a function simply wrapping an
instanceofcheck? Why not just useinstanceofdirectly?
Note: See
TracTickets for help on using
tickets.
Hi there and welcome to WordPress Trac!
What would be the benefit of adding a function simply wrapping an
instanceofcheck? Why not just useinstanceofdirectly?