• Resolved Jan

    (@locke85)


    Hi there,

    I’m encountering a persistent issue in the WordPress backend, where the interface becomes unresponsive or hangs on certain pages. Upon checking the error log, I found the following PHP warning:

    PHP Notice: map_meta_cap was called incorrectly. The post type “podcast” is not registered. This may cause unreliable behavior when checking the “edit_post” capability for this post type. (This message was added in version 4.4.0.)

    This warning occurs in /wp-includes/functions.php and seems to indicate that the custom post type podcast is not registered at the time when WordPress attempts to evaluate permissions.

    System Info:

    • WordPress Version: 6.8.1
    • PHP Version: 8.1
    • Theme: GeneratePress
    • WP_DEBUG: Enabled

    Observations:

    • The issue causes backend responsiveness problems (e.g., editor not loading, browser message “Page is unresponsive”).
    • The error appears during capability checks like current_user_can(‘edit_post’, $post_id) for post type podcast.
    • It seems the post type is either not registered early enough (e.g., before the init hook) or the capability is checked too early in the load process.

    Request:

    Could you please review if the custom post type podcast is being registered at the appropriate time (ideally within the init hook or earlier), and ensure that capability checks do not run before that?

    Let me know if you need additional details or a site export.

    Thanks in advance for your support!

    Best regards,

    Jan

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Serhiy Zakharchenko

    (@zahardoc)

    Hi @locke85,

    I’ve checked the plugin and couldn’t find any usage of the map_meta_cap() function. It can be a conflict with another plugin or the theme. Have you tried temporarily switching to a default theme and disabling other plugins one by one? This might help to find out where the conflict is coming from.

    Thread Starter Jan

    (@locke85)

    Hi @zahardoc,

    I’ve thoroughly reviewed my own theme and functions.php. None of my custom code touches the podcast post type directly, except for the standard filter ssp_register_post_type_args to add 'revisions' support — which is documented and used as intended.

    From the backtrace, the error is triggered during a wp_ajax_heartbeat request inside the post editor for a podcast post. At that point, current_user_can('edit_post', $post_id) triggers map_meta_cap(), but the podcast post type is not yet registered — resulting in the error and backend freeze.

    My suspicion is that the post type registration (register_post_type('podcast', …)) may not fire early enough for AJAX calls. Could you verify if the registration is hooked into init or runs earlier?

    Thanks again!

    Plugin Author Serhiy Zakharchenko

    (@zahardoc)

    @locke85

    Thank you for the additional details. I looked into this more deeply, and it appears to be a bug in WordPress core. The issue originates from the wp_refresh_post_lock() function, which is triggered by the heartbeat_received action before the init action runs:

    add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 );

    Specifically, the check current_user_can( 'edit_post', $post_id ) is located in wp-admin/includes/misc.php on line 1197 ( as of WordPress 6.8.1 ).

    So, I believe the bug would affect all custom post types that are registered during the init action — not just the podcast post type.

    Thread Starter Jan

    (@locke85)

    Thank for getting back @zahardoc

    Meanwhile I added them temp fix on my site:

    add_action('after_setup_theme', function () {
    if (!post_type_exists('podcast')) {
    register_post_type('podcast', [
    'label' => 'Podcast (early fallback)',
    'public' => false,
    'show_ui' => false,
    'supports' => ['title'],
    ]);
    }
    }, 5);

    …and created this ticket @wp_trac.

    Best regards,

    Jan

    Plugin Author Serhiy Zakharchenko

    (@zahardoc)

    @locke85

    Great, thanks for the code and creating a ticket in WP.

    Thread Starter Jan

    (@locke85)

    Hi @zahardoc

    Meanwhile, this went back and forth.

    To fix the issue on my site I added this php temporarily:

    // SSP - Temp to debug page freeze issue

    add_action('after_setup_theme', function () {
    if (!post_type_exists('podcast')) {
    register_post_type('podcast', [
    'label' => 'Podcast (early fallback)',
    'public' => false,
    'show_ui' => false,
    'supports' => ['title'],
    ]);
    }
    }, 5);

    add_action('init', function () {
    add_filter('map_meta_cap', 'debug_map_meta_cap', 10, 4);
    });

    // Fix: Force SSP podcast CPT registration to priority 10 instead of 11
    add_action('after_setup_theme', function () {
    // Make sure SSP class exists before manipulating
    if (class_exists('SSP_Post_Type')) {
    // Remove SSP registration at 11
    remove_action('init', [ 'SSP_Post_Type', 'register_post_type' ], 11);
    // Add SSP registration at 10
    add_action('init', [ 'SSP_Post_Type', 'register_post_type' ], 10);
    }
    }, 9);

    function debug_map_meta_cap($caps, $cap, $user_id, $args) {
    if (isset($args[0]) && is_numeric($args[0])) {
    $post = get_post($args[0]);
    if ($post && $post->post_type === 'podcast' && !post_type_exists('podcast')) {
    error_log('⚠️ map_meta_cap called for unregistered post type "podcast"');
    error_log('Capability: ' . $cap);
    error_log('User ID: ' . $user_id);
    error_log('Post ID: ' . $args[0]);

    // vollständiger Stacktrace
    ob_start();
    debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 20);
    $trace = ob_get_clean();
    error_log("Backtrace:\n" . $trace);
    }
    }

    return $caps;
    }

    Is there anything else that you can suggest based on the testing done by mindctrl ?

    Any advice is much appreciated.

    Best,

    Jan

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘map_meta_cap Warning: Custom Post Type “podcast” not registered in time’ is closed to new replies.