Opened 8 years ago
Closed 7 years ago
#37866 closed enhancement (fixed)
Introduce `$network_id` parameter in `get_user_count()`
Reported by: | flixos90 | Owned by: | flixos90 |
---|---|---|---|
Milestone: | 4.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Networks and Sites | Keywords: | has-patch commit has-unit-tests |
Focuses: | multisite | Cc: |
Description
The function get_user_count()
currently only supports checking for user count of the current network. Since it is easily possible to retrieve that value for other networks as well using get_network_option()
(since 4.4), I think we should support that functionality here as well by introducing an optional $network_id
parameter that will default to the current network.
Related: #37865
Attachments (3)
Change History (11)
#2
@
8 years ago
- Keywords 2nd-opinion added
An alternative approach could be:
- adjust logic in
wp_update_network_user_counts()
to count only users in the current network instead of all users - introduce
get_network_user_count( $network = null )
(returns the value of the network optionuser_count
) - introduce
get_global_user_count()
(returns the sum ofget_network_user_count()
for all networks) - deprecate
get_user_count()
and recommendget_global_user_count()
as replacement - replace Core usages of
get_user_count()
with eitherget_network_user_count()
orget_global_user_count()
(depending on context)
This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.
8 years ago
#4
@
8 years ago
Since the user count is actually global, but saved as a network option, supporting the $network_id
parameter doesn't currently have any actual value. Still, it would allow accessing the option of another network which theoretically might be different. Should we add the parameter (also for parity with get_blog_count()
in #37865) or not?
#5
@
7 years ago
- Keywords commit added; 2nd-opinion removed
- Milestone changed from Awaiting Review to 4.8
37866.diff looks good. Would it be helpful to add to the dockblock that this returns the current network's user count by default?
#6
@
7 years ago
- Owner set to flixos90
- Status changed from new to assigned
37866.2.diff adjusts the docblock to be more precise.
#7
@
7 years ago
- Keywords has-unit-tests added
37866.3.diff adds a unit test for the new parameter.
37866.diff introduces the new parameter.