Opened 6 years ago
Closed 6 years ago
#32481 closed enhancement (fixed)
Pass the original `$user_id` to the filter in `get_the_author_meta()`
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.3 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Options, Meta APIs | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
The "get_the_author_$field"
filter includes $user_id
, but there's no way to know whether that $user_id
was provided to get_the_author_meta()
or inferred from the current post.
So, I couldn't add a filter that acted only when I was sure get_the_author_meta()
was called to get meta about the current post author, as opposed to a specific user (or vice versa).
The attached patch would add a parameter to the filter with the original $user_id
value.
(The "the_author_$field"
filter already provides this information because the_author_meta()
passes the $user_id
it receives straight to the filter.)
Attachments (3)
Change History (9)
#1
@
6 years ago
- Keywords has-patch added
- Owner set to chriscct7
- Status changed from new to reviewing
Changed variable based on variable naming precedent from other functions, updated since and matched param comment to one above + precedent documentation for $old_value. Looks good.
#2
@
6 years ago
- Keywords commit added
- Milestone changed from Awaiting Review to 4.3
- Status changed from reviewing to accepted
Yep this is good to go. Solid work @dlh :)
#3
follow-up:
↓ 4
@
6 years ago
I'd prefer $original_user_id
for a better contextual variable name and for more clear filter doc purposes.
#4
in reply to:
↑ 3
@
6 years ago
Replying to sc0ttkclark:
I'd prefer
$original_user_id
for a better contextual variable name and for more clear filter doc purposes.
While I like the additional context it should be noted that we don't have any variable naming precedent for that for old userids like we do with $old_value, and also some people might not like having such a long variable name passed into a filter, particularly if they use a code editor or styling preference that limits the screen width, to say, 80 characters.
#5
@
6 years ago
we don't have any variable naming precedent for that for old userids like we do with $old_value
$ grep -nR "@param [a-zA-Z]\+ \$original_" src/
and similar greps show that we are pretty evenly split between $original_
, $raw_
, and $old_
. IMO, $original_
is the clearest, so let's go with it. (In your own callback functions, you can use whatever short variable name you want.)
Switch $_old_userid to $old_value per precedence in other functions. Update since to 3.4 and match param description to other