Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern moderation: Users appear as "unknown" in logs and internal notes #431

Closed
coreymckrill opened this issue Mar 10, 2022 · 2 comments
Closed
Labels
[Component] Pattern Directory The backend of the pattern directory: submission, management, etc

Comments

@coreymckrill
Copy link
Contributor

This is happening because the users aren't actually members of the Pattern Directory site, they are just in the global user table.

The Internal Notes plugin uses WP's rest api embedding feature to pull author data into the response that contains the note data, but again, that doesn't work when the "author" is not a member of the site. One solution to this might be to create a new rest endpoint (that maybe lives in wporg-mu-plugins?) for retrieving global user info. That could definitely have privacy implications, so it'd would probably require some capability checks before responding with any data.

@ryelle has this issue with the global user table come up anywhere else in the Pattern Directory? How is it being addressed there?

@coreymckrill coreymckrill added the [Component] Pattern Directory The backend of the pattern directory: submission, management, etc label Mar 10, 2022
@ryelle
Copy link
Contributor

ryelle commented Mar 10, 2022

I've run into that a few times, here and on WordCamp too, usually I end up adding a field to the API to return it, since PHP has no trouble getting that user data. For example, the author_meta field on Patterns, so that we can display the author name & avatar on pattern pages.

register_rest_field(
POST_TYPE,
'author_meta',
array(
'get_callback' => function( $post ) {
return array(
'name' => esc_html( get_the_author_meta( 'display_name' ) ),
'url' => esc_url( home_url( '/author/' . get_the_author_meta( 'user_nicename' ) ) ),
'avatar' => get_avatar_url( $post['author'], array( 'size' => 64 ) ),
);
},
'schema' => array(
'type' => 'object',
'properties' => array(
'name' => array(
'type' => 'string',
),
'url' => array(
'type' => 'string',
),
'avatar' => array(
'type' => 'string',
),
),
),
)
);

I think it would be great if we had a new endpoint to get this info. There's a related core ticket, but it has almost no activity in the last 5 years…

That could definitely have privacy implications, so it'd would probably require some capability checks before responding with any data.

Would it be that different from how the regular users endpoint works? I know that's been contentious in the past, so I think you're right that we should be careful, but just basic user info should be fine to be public. (I'm also thinking that in the case of the above use case, a site visitor wouldn't necessarily be logged in to get the pattern author data).

@ryelle
Copy link
Contributor

ryelle commented Apr 8, 2022

This was fixed with WordPress/wporg-mu-plugins#184 & WordPress/wporg-mu-plugins#192.

@ryelle ryelle closed this as completed Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Component] Pattern Directory The backend of the pattern directory: submission, management, etc
Projects
None yet
Development

No branches or pull requests

2 participants