Support » Plugins » Hacks » Custom Post Type; Admin Can't Publish or Delete

  • Resolved deanpence


    I’m having the strangest time getting capabilities to work correctly with a custom post type. I just want my custom post type to use the same capabilities as standard posts do. (It was working completely fine for a while, and then something changed—I’m not sure what yet—and I got frustrated and started with a completely fresh WordPress install, which didn’t fix anything. :))

    Here’s how I’m registering the post type: (See the end of this post for an explanation of my visibility settings.)

    I’m always logged in as an admin user.

    When I create one of these post types and click “Publish”, it saves as a draft. When I try to manually change the post status, I don’t have the option to publish:

    Also, when I click “Move to Trash” from the post list, I get the “Moved to trash” message, but it’s still in the list:

    In fact, when I click “Move to Trash”, my save_post action hook runs. That makes no sense.

    Any ideas? I don’t need custom capabilities. I just want to use the existing post capabilities.

    Possible caveats:

    I need only a few out-of-the-ordinary things. Posts of this type:

    • Don’t show up in nav menus.
    • Don’t have archives.
    • Don’t show up in search.

    Basically, the only way to get to one is if there’s a link directly to one of them.

Viewing 2 replies - 1 through 2 (of 2 total)
  • This was not a problem with capabilities at all. It was a problem with nonces.

    Since everyone else with this problem never left any details, all I did was:

    1. Stop using check_admin_referer [docs] and replace it with a simple nonce check with wp_verify_nonce[docs].
    2. Make sure that wp_nonce_field [docs] and wp_verify_nonce were using the correct arguments in the correct order.

    (If you use the code below, use your own nonce name and action strings.)

    In the metabox:

    wp_nonce_field('nonce_action', 'nonce_name');

    In the ‘save_post’ hook:

    if (!wp_verify_nonce($_POST['nonce_name'], 'nonce_action')) {



    I have this same problem, but in my case I create 3 CPTs and all just show to publish as draft, but just only save like draft, the others two publish normal.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post Type; Admin Can't Publish or Delete’ is closed to new replies.