Draft preview issues on main site in multisite setup

Environment:

  • WordPress 5.4.1 multisite
  • PHP 7.3
  • Apache

Problem:
The draft preview of pages and posts works poorly on my main site. The other sites works just fine. The setup has a mother theme and all sites has their own child theme. Every other time (sometimes more) I’m greeted with the message: “Sorry, you are not allowed to preview drafts.”.

The message is outputed in wp-includes/revision.php:

<?php
/**
 * Filters the latest content for preview from the post autosave.
 *
 * @since 2.7.0
 * @access private
 */
function _show_post_preview() {
	if ( isset( $_GET['preview_id'] ) && isset( $_GET['preview_nonce'] ) ) {
		$id = (int) $_GET['preview_id'];

		if ( false === wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . $id ) ) {
			wp_die( __( 'Sorry, you are not allowed to preview drafts.' ), 403 );
		}

		add_filter( 'the_preview', '_set_preview' );
	}
}

Tried solutions to the problem (no luck so far):

  • Flush permalinks
  • Disable all plugins
  • Switched to a child theme from another site on the multisite where the draft works.
  • Check to see if site url and home url are the same in the databse.
  • Cleared cache.

My .htaccess (nothing fancy):

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) wp/$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ wp/$2 [L]
RewriteRule . index.php [L]


Header set Access-Control-Allow-Origin "*"

I’m really scratching my head on this one. Any ideas what might be the problem? Based on the function outputing the message I recon it have something to do with the nonce? But why only on my main site?

This topic was automatically closed after 42 days. New replies are no longer allowed.