Change WordPress user roles and capabilities › Forums › Bug Reports › Infinite loop with ure_restrict_edit_post_type
- This topic has 3 replies, 3 voices, and was last updated 1 week ago by edering.
-
AuthorPosts
-
08/01/2025 at 15:35 #8779AustinParticipant
We’ve been using the following block of code with URE Pro for the last several years to redirect based on some custom criteria. Well recently indiviuals with the custom role of Scholarship can no longer sign in. Instead they see an infinite redirect loop to this page:
/wp-admin/edit-tags.php?taxonomy=post_tag&post_type=tribe_events
. Any ideas how to fix. This filter was based off the one provided in the docs: https://www.role-editor.com/documentation/hooks/ure_restrict_edit_post_type/.`
// URE to allow Scholarship Role access to Scholarship plugin while restricting Pages for user; and allow Applications & Tools Role access to Applications & Tools CPT while restricting Pages for custom Page Editor role
add_filter(‘ure_restrict_edit_post_type’, ‘exclude_posts_from_edit_restrictions’,10,1);
function exclude_posts_from_edit_restrictions($post_type) {
$restrict_it = $post_type;
$user = wp_get_current_user();
if ( empty( $user) || !is_array( $user->roles ) ) {
return $restrict_it;
}
if ( in_array( ‘scholarships’, $user->roles ) ) { // Role ID
if ($post_type==’scholarship’) { // CPT ID
$restrict_it = false;
}
}
elseif ( in_array( ‘custom-page-editor’, $user->roles ) && in_array( ‘applications_tools’, $user->roles )) { // user has both roles at the same time
if ( $post_type===’app_tool’ ) {
$restrict_it = false; // Do not restrict editing for Applications & Tools
}
}
elseif ( in_array( ‘custom-page-editor’, $user->roles ) && in_array( ‘course_selections’, $user->roles )) { // user has both roles at the same time
if ( $post_type===’course-selection’ ) {
$restrict_it = false; // Do not restrict editing for Course Selection guide
}
}
return $restrict_it;
}
// end URE to allow Scholarship Role and Applications access`
14/01/2025 at 13:20 #8790ederingParticipantHi. Austin posted this for us. Do you have any ideas on how to fix this?
15/01/2025 at 13:38 #8793VladimirKeymasterHi @edering,
I can not reproduce the described issue with provided code sample. I suppose that your site plugins and data are involved.
Is it possible to take a copy of the stage site with such issue (without critical data) using UpdraftPlus WP backup plugin (database export .sql file and and plugins, themes folders)? If Yes, send URL and credentials to support email. I will setup it at my local development environment and try catch a reason.
15/01/2025 at 13:46 #8794ederingParticipantHi @Vladimir. I am going to clone the Production to Staging and send you access via email. You actually already have a User but I will send you details. I will also tell you the User that is having the issue so you can review the user/role. It should come via email in 10 minutes. Thanks
-
AuthorPosts
- You must be logged in to reply to this topic.