0

I am not very experienced with WordPress, so please bear with me if I do not use the right words or concepts.

I've been asked to find out why it isn't possible to update a page in a (quite old) WordPress installation. It's using the Block Editor and I've managed to find out this:

  • It's only the front page that has this problem as far as I can see.
  • When updating the page, an ajax call to https://<domain>/wp-json/wp/v2/pages/<id>?_locale=user is made, and when I'm trying to update the front page it returns status 403 (and the page is not updated). On other pages it returns 200 and everything works.
  • The page has been updated numerous times before, it has more than 200 versions.
  • I don't think anything (core, plugins or themes) has updated automatically since the previous edit (which happened about two months ago).

I understand that this might have lots of reasons, for example the various plugins that are installed, but I'm hoping this is either a well-known problem (even though I haven't managed to find something by searching) or that there are some obvious things to check out (for example page permissions, or what have you).

Thanks!

2
  • What theme are you using? Can you post a list of plugins being used? Also check if the theme has any custom code specifically in functions.php Also, it would be worth it to update everything incrementally. Would require a some QA time depending on the type of site it is (ecommerce, blog...).
    – Leo Fisher
    Jan 24 at 20:46
  • Assuming you're using the latest WP version this could be security software at your host or in a plugin, usually if the REST API responds with a 403 it has a message with it that would be useful, if it's not a JSON REST API 403 response and it's instead Apache/Nginx/etc then it's not the REST API doing the 403 and you'd need to make that clear when asking.
    – Tom J Nowell
    Jan 24 at 21:09

2 Answers 2

2

I found the source of the error, and I'll post my solution here if some lost soul with the same problem happens to stumble upon this question.

The culprit was a piece of JavaScript at the start of the page (some old piece of Google Tagmanager/Analytics that didn't even work).

I found it by making a copy of the page and removing piece by piece until it was possible to save without an error.

I don't know why this script-code became a show-stopper all of a sudden, but there you have it! I am happy and hopefully the editors of the site will be too.

1

Based on your description, the issue with being unable to update the front page of an older WordPress site, resulting in a 403 error during an AJAX call, could be caused by several factors. Here are some potential causes and steps you can take to diagnose and resolve the issue:

Memory limit: Always a good idea to try increasing your memory limit first, in your wp-config.php file add this like of

define('WP_MEMORY_LIMIT', '256M');

User Permissions: Ensure that the user account you're using has the necessary permissions to edit the front page. Sometimes, permissions might be set differently for the front page compared to other pages.

Security Plugins: If there are security plugins installed, they might be blocking the AJAX request. Check the settings of any security plugins to see if they are causing the issue. Temporarily disabling these plugins can help determine if they are the source of the problem.

Page Edit Lock: Since the page has many versions (over 200), it's possible that the page might be locked or there's an issue with the revisions. Try clearing some of the older revisions to see if that resolves the issue.

.htaccess File: The .htaccess file can sometimes cause 403 errors. Check this file for any incorrect settings or rules that might be blocking access to the WordPress REST API.

File Permissions: Incorrect file permissions on the server can cause 403 errors. Ensure that the file permissions for WordPress files and directories are set correctly.

WordPress REST API: Since the error occurs with an AJAX call to the WordPress REST API, there might be an issue with the REST API itself. Check if the REST API is functioning correctly on your site.

Debugging: Enable WordPress debugging by setting WP_DEBUG to true in the wp-config.php file. This might provide more detailed error messages that can help pinpoint the issue.

Conflict Check: Disable all plugins and switch to a default theme (like Twenty Twenty-One) to see if a plugin or theme conflict is causing the issue. If the problem resolves, re-enable them one by one to identify the culprit.

PHP Version: Ensure that the server is running a PHP version that is compatible with your WordPress version. Outdated PHP versions can cause unexpected issues.

WordPress and Plugin Updates: Even though you mentioned that nothing seems to have updated automatically, double-check to ensure that WordPress core, themes, and plugins are up to date. An outdated environment can lead to various issues.

Browser Console: Check the browser console for any JavaScript errors that might be occurring when you attempt to update the page. These errors can provide clues about what's going wrong.

Server Logs: Review your server's error logs. These logs often contain details about server-side issues that lead to 403 errors.

Caching: If you're using a caching plugin or server-side caching, clear the cache. Sometimes, caching issues can lead to unexpected behavior in WordPress.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.