Programmatically Controlling Editus Activation

The first thing first: Editus cannot, and should not do things WordPress doesn’t allow. So if a user doesn’t have a privilege to edit and save a post, Editus cannot and should not allow the user to do so. Editus is designed to follow the privilege level provided by WordPress.

Given that, it’s possible to further control the activation of Editus. You can write a filter function for ‘lasso_user_can_filter’ in PHP. Your custom PHP codes can be inserted into your theme’s functions.php file. Or more preferably, you can inject the following codes using a custom php plugin.

Here is an example code that would let you activate Editus only when the post type is ‘page’ and the id is 11.

To add in your own logic, replace the lines starting with if ($post_type == 'page') { and have the function return true when Editus should be activated, and false when it shouldn’t be activated.

function editus_user_can( $result, $action, $postid ) {
	if (!$result ) {
                return false;
	} else {
                $post_type = get_post_type();
                if (empty($post_type)) { // this is necessary for save operation
                    return $result;
                }
                
                // you can replace the following code with your logic
                if ($post_type == 'page') {
                    $postid = get_the_ID();
                    if ($postid == 11) {
                         return true;
                    }
                }
                return false;
	}
}
add_filter( 'lasso_user_can_filter', 'editus_user_can', 10, 3 );