Skip to content

Image Prompt Generation: Permission error for a post says "generate excerpts"Β #1233

Closed

Description

@maheshbohara

Description

When a user runs the ai/image-prompt-generation ability for a post they cannot edit, the error says they cannot generate excerpts:

You do not have permission to generate excerpts for this post.

The message was copied from Excerpt Generation. The same method in Generate_Image_Prompt.php already says "You do not have permission to generate image prompts." for the check without a post, so only the post check has the wrong wording.

I expect: "You do not have permission to generate image prompts for this post."

Step-by-step reproduction instructions

  1. Enable the Image Generation feature under Settings > AI.
  2. Log in as a Contributor.
  3. Run the ability for a post written by another user, for example post 1 by the admin:
POST /wp-json/wp-abilities/v1/abilities/ai/image-prompt-generation/run

{"input":{"content":"A cat","context":"1"}}

Expected: 403 insufficient_capabilities with "You do not have permission to generate image prompts for this post."

Actual: 403 insufficient_capabilities with "You do not have permission to generate excerpts for this post."

Screenshots, screen recording, code snippet

Response, sent from the Contributor's session in Chrome:

HTTP 403
{"code":"insufficient_capabilities","message":"You do not have permission to generate excerpts for this post.","data":{"status":403}}

The line is includes/Abilities/Image/Generate_Image_Prompt.php:170.

Environment info

  • WordPress 7.1.3 (wp-env, PHP 8.3.35)
  • AI plugin: develop at a778c74 (1.4.0)
  • Theme: Twenty Twenty-Five
  • Chrome on macOS

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except the AI plugin.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions