Author selection for Pages should not include users with roles lower than Editor
Expected behavior
List doesn't contain users who have a role lower than Editor.
Actual behavior
List contains users who have a role lower than Editor, although they cannot technically publish Pages.
When tapping Publish:
- Self-hosted sites without a WordPress.com connection do not throw an error.
- WordPress.com sites throw an error from the backend that is presented by the user interface.
Error Domain=WordPressKit.WordPressComRestApiError Code=2 "Assigned author cannot publish post." UserInfo={NSLocalizedDescription=Assigned author cannot publish post., WordPressComRestApiErrorCodeKey=unauthorized, WordPressComRestApiErrorMessageKey=Assigned author cannot publish post.}
Steps to reproduce the behavior
Prerequisites: Two users exist on a blog - one Administrator role, and one lower than Editor (e.g. Author or Contributor).
- Log into the app as the Administrator user
- Tap the FAB and select Site page to create a page
- Choose any layout
- ℹ️ If the Blank Page layout was chosen, populate a title
- In the Page settings tap Author
- Observe: The list of users
Notes
WordPress.com's web interface (Calypso) allows one of these users to be set and for the Page to be published without error.
Tested on iPhone 14, iOS 16.2, WPiOS 21.5
WPAndroid issue: https://github.com/wordpress-mobile/WordPress-Android/issues/17739
This now works better as the error message contains the reason why it fails, which I think is an acceptable solution:
– less logic to be hardcoded in the app – no guessing why a user is missing from the list