Opened 9 months ago
Last modified 9 months ago
#64131 new feature request
A new function to test if a thing is an instance of the WP_User class
| Reported by: | profiletoggler | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Users | Version: | 6.9 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
<?php function is_wp_user( $thing ) { return ( $thing instanceof WP_User ); }
Change History (2)
#2
in reply to: ↑ 1
@
9 months 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hi there and welcome to WordPress Trac!
What would be the benefit of adding a function simply wrapping an
instanceofcheck? Why not just useinstanceofdirectly?