[Plugin: User Access Manager] Feature Request: the_content
-
I was wondering if the_content hook stil works with UAM and it does not as a like it.
Why am I asking: If you write a plugin, that does some custom content rendering using this hook you don’t want this to effect access issues. But actually UAM overrides the content of a post when no access is granted. So it depends which plugin is ‘faster’.
For example, imagine some plugin code like
add_filter('the_content', 'myplugin_the_content'); function myplugin_the_content($content){ return "my custom output"; }If a user has no access to a post there will most likely show “my custom output” up though!
I am not sure how to fix this problem nicely. Maybe UAM can suppress the ‘the_content’ filter for posts with no access…
A solution that you can implement in your third party plugin is the following:
add_filter('the_content', 'myplugin_the_content'); function myplugin_the_content($content){ global $post; global $userAccessManager; $access = true; if (isset($userAccessManager)) { $uamAccessHandler = $userAccessManager->getAccessHandler(); $access = $uamAccessHandler -> checkObjectAccess($post->post_type, $post->ID); } //if UAM says access denied, do not continue! if(!$access) return $content; //otherwise go on with you processing return "my custom output"; }
The topic ‘[Plugin: User Access Manager] Feature Request: the_content’ is closed to new replies.