#21426 closed enhancement (fixed)
Add get and set methods to WP_User_Query
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | 3.1 |
Component: | Query | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
User queries are confusing to alter, so it would be helpful to have get and set methods a la WP_Query when altering WP_User_Query::query_vars in a filter or action.
do_action_ref_array( 'pre_user_query', array( &$this ) );
Without these methods, you have to do things like:
$query->query_vars[ 'meta_query' ] = array( $memory_hog );
Instead of:
$query->set( 'meta_query', array( $memory_hog ) );
Attachments (3)
Change History (14)
#3
@
12 years ago
One thing I don't like about WP_Query::get() is that it returns an empty string, rather than something like null or false. See #19243. It would be nice if we changed how WP_Query::get() works in the process.
#5
@
12 years ago
I like functions to return absolutely nothing in those cases, but you pick false / null if there's a consistency issue with WP_Query
#6
@
12 years ago
null would be the same as absolutely nothing, so that's fine. I may try to convert WP_Query::get() over to null in the future.
#7
@
12 years ago
- Keywords commit needs-unit-tests added
21426.diff — could use some basic unit tests.
I personally don't find
WP_Query->set()
andWP_Query->get()
all that useful, but I do use them, so I don't know. +1 for consistency, I guess.