Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

Users without WordPress.com connection attempting to use AI Assistant features (featured image generation, content completion) received the generic WordPress error "Sorry, you are not allowed to do that." This provided no actionable information about the connection requirement.

Changes

Modified Jetpack_AI_Helper to intercept connection-related errors and return clear, actionable messages:

  • get_dalle_generation(): Detects unavailable_site_id and missing_token errors, returns: "Your account must be connected to WordPress.com to generate AI images. Please connect your account from the Jetpack settings screen to proceed."

  • get_gpt_completion(): Same error detection pattern with contextually appropriate messages for text generation.

if ( is_wp_error( $site_id ) ) {
    if ( 'unavailable_site_id' === $site_id->get_error_code() ) {
        return new WP_Error(
            'unavailable_site_id',
            __( 'Your account must be connected to WordPress.com to generate AI images. Please connect your account from the Jetpack settings screen to proceed.', 'jetpack' ),
            array( 'status' => 403 )
        );
    }
    return $site_id;
}

Error codes and HTTP status codes remain unchanged for backward compatibility.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…n is missing

Co-authored-by: annezazu <26996883+annezazu@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve UI messaging when AI Assistant requires WordPress.com connection Improve error messaging for AI Assistant when WordPress.com connection is missing Dec 18, 2025
Copilot AI requested a review from annezazu December 18, 2025 02:45
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.

2 participants