Home›Topic Tag: Controlling access to content editing
Topic Tag: Controlling access to content editing
Access plugin allows you to control access to content editing for different users. You can set access rules for entire user types or for specific users.
When you ask for help or report issues, make sure to tell us on which content and user types you are trying to apply access control.
Problem: I have a custom role that should be able to submit a Form to add or edit a child post, but the parent post options are not shown in the select field in the Form. This was working before a recent update.
Solution: Check your custom code to confirm that redirects set up to block access to the back-end of the site are not applied to admin-ajax.php requests. Add some conditional logic to prevent those redirects as needed, like in the following code example:
/**
* Block wp-admin access for non-admins (not while doing AJAX, see https://toolset.com/forums/topic/custom-role-no-longer-able-to-perform-same-tasks/)
*/
function ace_block_wp_admin() {
if (!current_user_can('edit_users') && ( !defined('DOING_AJAX') || !DOING_AJAX ) ) {
wp_safe_redirect( '/my-account');
exit;
}
}
add_action( 'admin_init', 'ace_block_wp_admin' );
Problem: The "edit post link" is not appearing for certain roles despite having Form controls set appropriately in Toolset Access Control.
Solution: Check the post type access control settings to ensure Access is managing this post type. If not, activate Access control for this post type and set the controls appropriately.
Problem: I would like to restrict access to posts using Toolset Access and a custom field on each post that stores a numeric User ID. The User whose ID is stored in the custom field should have access to the post, but no one else should. This doesn't seem to be working as expected.
Solution: The "own" or ownership referred to in Access can only be defined as the post author, not a custom field value or any other association type. In other words, the post's author is the only owner of a post, as far as Access is concerned. If you'd like to use this Access feature to limit or allow editing of "own" posts, you must set each User as the author of their own post(s).
To restrict access to editing posts with Forms, you must use the Toolset Forms tab in Toolset > Access Control to modify the access settings per Form.