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

Look for private status posts if editor or admin #1813

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

oscarssanchez
Copy link
Contributor

@oscarssanchez oscarssanchez commented Jun 22, 2020

Description of the Change

Hi @tlovett1 ,

Could you please review this PR which addresses #1800?

This changes the is_user_logged_in() check in favor of checking if the current user is either an editor or an administrator, and displays private posts only to them. Both in the frontend and in the admin.

As per WP documentation, private posts should only be visible to editors and administrators: https://developer.wordpress.org/reference/classes/wp_query/#status-parameters and without Elasticpress enabled, I could confirm this was true.

Additionally, the PR solves another bug I spotted, which lets authors and contributors see just anyone private posts in the admin if Elasticpress is enabled.

Alternate Designs

Benefits

Not allowed users won't see post they should not. Allowed users should be able to see private posts in the frontend.

Possible Drawbacks

Verification Process

  • Create a private post.
  • Index with Elasticpress.
  • Query in the frontend as an editor/admin and see private post.
  • Query in the backend as an author/contributor and no private post is returned.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

Changelog Entry

@oscarssanchez
Copy link
Contributor Author

Also confirmed it fixes #1870

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant