2

I have been working with a client to migrate a site to a new host provider. I migrated the db manually, and have run into an issue that I have never seen before. I can edit ALL existing posts, but when I try to create a new post – in the Permalink field, under “Enter title here” I see: Permalink: ?preview=true

enter image description here

When I publish or save the draft, I receive: Sorry, you are not allowed to edit this post.

enter image description here

Also, on the posts, there is no preview button.

Steps taken in order to try to fix:

  1. I have turned on WP_debug, which was little help for this issue.

  2. I switched my theme to 2017 to see if there were theme conflicts occurring, no help.

  3. I disabled all plugins after switching the theme, no help.

  4. I compared my wp_capablities row in wp_usermeta to other existing wp_capabilities row;

  5. I did try a sql statement to replace the admin cap, i.e.:

UPDATE wp_usermeta SET meta_value = REPLACE( meta_value, 'a:1:{s:13:\"administrator\";s:1:\"1\"','a:1:{s:13:\"administrator\";b:1' );

So now my admin cap is set to: a:1:{s:13:\"administrator\";b:1' )

But I am still receiving the same results.

I was hoping someone might recognize this error and be able to point out where I screwed up.

Thx! Chipleh

  • Great situation. Try getting into the database to get the desired result. – Vishal Kumar Sahu May 22 '17 at 19:00
  • Thanks for that, I am searching right now for what the desired result actually is... any idea why that permalink would be fixed to my post, instead of being able to edit it? Is it a user permission error, or a corrupted db table issue? I am not sure why this is occurring to begin with. – Chipleh May 22 '17 at 19:18
  • 1
    If your using a new domain name then you need to go to your database and change the domain name in the options table both places to your new domain name next go to the permalink page and change the permalink to default from custom and save then change it back to custom and save again this should force the .htaccess page to reset or you can do this manually. After that log out and clear cache then re login to your site and see if the problem has cleared. – Sam May 22 '17 at 19:35
  • 1
    @Sam fixing options table is not enough. You may have references to old domain in other tables ( for example posts ), as well. – Frank P. Walentynowicz May 22 '17 at 20:05
  • You should retry installation or copying... I guess process has missed some files. – Vishal Kumar Sahu May 23 '17 at 12:03
1

There are, still, references to old domain in your database, which have to be fixed.

Step 1: go to Settings -> Permalinks and click on Save Changes button. This will fix your permalinks.

Step 2: install and activate Better Search Replace plugin. Go to Tools -> Better Search Replace. Replace the old domain ( example.com ) to the new one ( whatever.net ) in all tables.

You can skip Step 2, if the domain name didn't change.

Make sure that admin cap is exactly a:1:{s:13:"administrator";b:1;}.

  • 1
    Hi Frank,Thank you for that. I have done Step 1, Step 2 is a non-issue, and indeed, the admin caps are set to: a:1:{s:13:"administrator";b:1;} - still no luck... ?preview=true - when I instantiate a new post, have you ever seen that? Because I have not. – Chipleh May 22 '17 at 19:55
  • Try to check, if the problem disappears, after disabling all plugins and switching to one of default themes. If it works, then activate plugins, one at the time, checking again. That should help to isolate the plugin causing this problem. If that does not help, I don't know, at the moment, what might cause this. – Frank P. Walentynowicz May 22 '17 at 20:25
  • Thanks again Frank, yep, I have done what you mentioned, as I've read that as being the first steps in diagnosing Wordpress issues, but to my chagrin, none of those solutions solved my issue. I have rebuilt several times using various versions of Wordpress now, along with the same db, and the same problem exists, so it must be a problem within the db itself, I just can't figure out what it is. – Chipleh May 23 '17 at 14:04
  • Welp, in the end, I was not able to resolve my issue without rebuilding the site and using Wordpress>Tools>Export>Posts/Media in order to get all the content, which was less than desirable, but I'm back up and running again. Thanks for your suggestions Frank. I gave you the solution, since your comments were the most helpful. – Chipleh May 23 '17 at 18:52
0

SO is not formatting the code???

Although my answer doesn't solve your permission issue, but it may help when you retry to rebuild the site after several failures.

Once I copied my online wordpress to local, to make it work I just followed these steps-

  1. Copied all files and folders
  2. Copied database and added to local database
  3. Edited the wp-config.php file as following along with database credentials (Hope it works for you)-

    //Part of wp-config file before require_once(ABSPATH . 'wp-settings.php');

    $content_directory = "/content"; $plugins_directory = "/code";

    $currenthost = "http://".$_SERVER['HTTP_HOST']; $currentpath = preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME'])); $currentpath = preg_replace('//wp.+/','',$currentpath); define('WP_HOME',$currenthost.$currentpath ); define('WP_SITEURL',$currenthost.$currentpath );

    define('WP_CONTENT_URL', $currenthost.$currentpath.$content_directory); define( 'WP_CONTENT_DIR', dirname( FILE ) . $content_directory );

    define('DOMAIN_CURRENT_SITE', $currenthost.$currentpath );

    define('WP_PLUGIN_DIR', WP_CONTENT_DIR . $plugins_directory ); define('WP_PLUGIN_URL', WP_CONTENT_URL. $plugins_directory); define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR. "/multicode" ); define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL. "/multicode" );

    define('UPLOADS', WP_CONTENT_DIR.'/files');

    define('WP_POST_REVISIONS', 2); define('WP_DEBUG_DISPLAY', false);

    @define('ADMIN_COOKIE_PATH', './');

    /* MANUAL CODE ENDS HERE */

Or you can manually specify the $currenthost and $currentpath specific for your installation. And I was able to get everything same on local.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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