Skip to content

wpce_enable_for_post v3.20

Filters whether a certain post should editable by the WPCE.

This hook is only applied if the post's type generally is WPCE-enabled through wpce_enable_for_post_types, so strictly speaking, it only allows to disable the WPCE for individual posts.

WARNING

Disabling the WPCE for individual posts also disables all the other post-related handling the WPCE does, e.g. turning off the Gutenberg editor or rendering the post content in the frontend. It makes that particular post behave as if the WPCE was not installed at all.

Parameters

  1. bool $enabled

    Whether the WPCE should be enabled for the post.

  2. WP_Post $post

    The post to check.

Example

php
add_filter('wpce_enable_for_post', function (bool $enabled, WP_Post $post) {
	// Disable the WPCE for all posts published before 2024
	if ($post->post_date < '2024-01-01 00:00:00') return false;

	return $enabled;
}, 10, 2);