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

fix: also search for coauthor posts by term slug #1954

Merged
merged 6 commits into from
Nov 18, 2024

Conversation

leogermani
Copy link
Contributor

@leogermani leogermani commented Nov 13, 2024

All Submissions:

Changes proposed in this Pull Request:

When searching for posts from an author that is a WP User (not a guest author), we should also (actually maybe only) search by term slug.

This PR adds a few extra conditions to make sure we find posts by an author when searching by terms.

The specific case we are fixing here is from users that ended up with their Display Name as the term name, and thus the search term name using the user_login as input would never find anything. We also need to search by user_nicename and make sure we search in the slug field.

How to test the changes in this Pull Request:

  1. Activate CoAuthors Plus
  2. Create a user and assign a few posts to it
  3. Create a post and assign this user as a secondary co-author (a co-author, but not the author on the post_author field in the database
  4. On a page, add a Home Page posts block and filter by this author
  5. Make sure all the posts show up, including the one they are not the main author (on trunk it won't show up)
  6. Add this somewhere:
// Disable guest authors before CoAuthors plus is initialized
add_action(
	'init',
	function() {
		add_filter( 'coauthors_guest_authors_enabled', '__return_false' );
	},
	9
);
  1. Make sure the block still fetch the correct posts.
  2. Remove the snippet to re-enable Guest Authors
  3. Create a guest author
  4. Create a post and assign only the guest author to it.
  5. You can confirm and see that the post_author field in the DB still points to your admin
  6. In the HPP block, filter posts by the guest author and confirm it works
  7. Now filter posts by your admin, and confirm the post by the guest author is NOT returned

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@leogermani leogermani self-assigned this Nov 13, 2024
@leogermani leogermani requested a review from a team as a code owner November 13, 2024 19:50
Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as described!

@leogermani leogermani merged commit 49357ff into trunk Nov 18, 2024
8 checks passed
@leogermani leogermani deleted the hotfix/hpp-find-coauthors-posts branch November 18, 2024 14:02
Copy link

Hey @leogermani, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

@leogermani leogermani restored the hotfix/hpp-find-coauthors-posts branch November 18, 2024 14:17
@leogermani leogermani deleted the hotfix/hpp-find-coauthors-posts branch November 18, 2024 14:24
matticbot pushed a commit that referenced this pull request Nov 29, 2024
# [4.5.0-alpha.1](v4.4.0...v4.5.0-alpha.1) (2024-11-29)

### Bug Fixes

* also search for coauthor posts by term slug ([#1954](#1954)) ([49357ff](49357ff))
* **ras-acc:** correct spacing issue around saved credit cards ([#1980](#1980)) ([52a5c57](52a5c57))
* **ras-acc:** fix display issues with Additional Fields ([#1979](#1979)) ([b9390ef](b9390ef))
* **ras-acc:** remove space caused by empty divs ([#1978](#1978)) ([8cb6ead](8cb6ead))

### Features

* add Bluesky support to the Author Profile, List blocks ([#1969](#1969)) ([d26a7e4](d26a7e4))
* add support for Newspack Guest Contributor in HPP blocks ([#1934](#1934)) ([c16849e](c16849e))
* merge RAS-ACC work into trunk ([#1977](#1977)) ([2eeaa89](2eeaa89))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 4.5.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Dec 9, 2024
# [4.5.0](v4.4.0...v4.5.0) (2024-12-09)

### Bug Fixes

* also search for coauthor posts by term slug ([#1954](#1954)) ([49357ff](49357ff))
* **modal-checkout:** allow all gateway assets ([#1988](#1988)) ([e371e30](e371e30))
* **modal-checkout:** handle paypal ([#1985](#1985)) ([9bb2b8c](9bb2b8c))
* **ras-acc:** correct spacing issue around saved credit cards ([#1980](#1980)) ([52a5c57](52a5c57))
* **ras-acc:** fix display issues with Additional Fields ([#1979](#1979)) ([b9390ef](b9390ef))
* **ras-acc:** remove space caused by empty divs ([#1978](#1978)) ([8cb6ead](8cb6ead))
* remove reCaptcha for WooCommere code from modal checkout ([#1984](#1984)) ([8e250eb](8e250eb))

### Features

* add Bluesky support to the Author Profile, List blocks ([#1969](#1969)) ([d26a7e4](d26a7e4))
* add CSS class to variation buttons for tracking ([#1989](#1989)) ([910e6b1](910e6b1))
* add support for Newspack Guest Contributor in HPP blocks ([#1934](#1934)) ([c16849e](c16849e))
* merge RAS-ACC work into trunk ([#1977](#1977)) ([2eeaa89](2eeaa89))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 4.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants