• Ovidiu

    (@ovidiu)


    I have the problem that if I go to this plugin’s settings page and select:

    Redirect user blog start page: Setup what happen if a user visit a post/page with no access.
    then I can’t visit any pages. all redirect to the home page. even if none is protected ??

    I have to put this setting to NO then all works as expected. I can visit all unprotected pages and if I hit a protected one I get a 404 error.

    works for me but it really needs fixing!

    thanks

    https://www.ads-software.com/extend/plugins/user-access-manager/

Viewing 12 replies - 1 through 12 (of 12 total)
  • pigmonkey

    (@pigmonkey)

    I’m having the same problem. When I turn on redirects, I get sent to the redirect page whether I’m logged out (and so have no permission) or logged in as an admin (and so have full permissions).

    Thread Starter Ovidiu

    (@ovidiu)

    thx for confirming. now lets wait for the author’s response…

    Peter Wilson

    (@peterwilsoncc)

    I was having the same problem too.

    My research:

    Change line 300 of user-access-manager.php to:
    add_action('template_redirect', array(&$userAccessManager, 'redirect'), 10);

    In UserAccessManager.class.php
    Change line 2042 to:
    $url = get_permalink($uamOptions['redirect_custom_page']);
    comment out line 2043

    I think the original filter was testing the page being loaded before it was known by the system.

    I’ve done some rudimentary checking to make sure this hasn’t messed anything up, I’ll post again when I have my results

    Peter Wilson

    (@peterwilsoncc)

    Above caused changes caused some problems with file management so in user-access-manager.php make the changes detailed at https://wordpress.pastebin.com/CGJCT5si

    Another, unrelated, change I’ve made is to redirect protected files to the same page by adding

    $this->redirectUser($object);
    // above
    wp_die(TXT_UAM_NO_RIGHTS);

    in UserAccessManager.class.php

    Plugin Author GM_Alex

    (@gm_alex)

    Does the solution above works for all you guys? If yes, I will add it for the next release.

    mercere

    (@mercere)

    peterwilsoncc’s change to user-access-manager.php fixed some of the problems I was seeing with getting redirected to the front page when access was denied. But before I make the second change, there are two instances of “wp_die(TXT_UAM_NO_RIGHTS);” in UserAccessManager.class.php. Should I add the line “$this->redirectUser($object);” above BOTH instances?

    mercere

    (@mercere)

    I tried the insertion ahead of both instances, with no improvement. In my case, I’m trying to integrate UAM with the multi-language plugin WPML, so the situation is complex. When going to example.org/restrictedpage Peter’s change to user-access-manager.php fixed the problem of redirecting to the front page (it now redirects to the page it’s supposed to according to the UAM settings).

    But when going to example.org/fr/restrictedpage (the French translation of the restricted page) it’s still getting redirected to the front page. Note that the /fr/ means the request gets intercepted and processed by WPML to return the French translation of ‘restrictedpage’, which is why this gets complex.

    i can’t seem to figure out a way to redirect a user after they log in to either a specific page or anything but the wp admin.

    is this possible with this plugin?

    I know it’s been a while, but I wanted to post my experience with the fixes suggested by peterwilsoncc. I made the change noted on https://wordpress.pastebin.com/CGJCT5si

    and it solved the problem somewhat (selecting an existing page still didn’t work, but Custom URL did), but after uploading the code, WP stopped recognizing my custom page templates – all pages just showed the default.

    Any ideas how I can make the redirect function properly AND use my custom page templates?

    I am having the same problem at wywalk. I added the code here https://wordpress.pastebin.com/CGJCT5si and it fixed the redirection problem with the plugin. BUT my custom templates broke. Anybody know a fix for this?

    Same here! Looking for the ability to redirect while still using my custom templates. Anyone get a handle on this?

    In looking in to this further, I’ve found that the plugin redirects just fine, as long as you’re not using custom permalinks or custom page templates. But what’s the fun in that?

    The code pasted above changes the condition and hook that call the function but, as noted, breaks when custom templates are used. In looking in to the actual ‘redirect’ function that’s being called, I found that permalinks were causing the break. I’m not sure if the plugin developer built something in to deal with permalinks or just forgot but the function was looking for variables that just don’t exist under custom permalinks. Rather than try to totally re-engineer the code, I simply grabbed the variables that did exist (at least for my permalinks) and swapped them in.

    So here’s my fix:
    Do NOT swap in the code pasted above to user-access-manager.php; leave that file untouched.

    Instead, go to UserAccessManager.class.php and find ‘public function redirect’. There you’ll find a multi-conditional statement that determines whether the user is attempting to access a post, a page or category archive. My code is pasted below, commenting out the original lines and inserting the lines needed. Again, these new lines worked for my permalink structure (postname/postid); not sure if they’ll work for others.

    if (isset($pageParams->query_vars['p'])) {
    	$object = get_post($pageParams->query_vars['p']);
    	$objectType = $object->post_type;
    	$objectId = $object->ID;
    //} elseif (isset($pageParams->query_vars['page_id'])) { // sfc: for use with no permalinks
    } elseif (isset($pageParams->query_vars['pagename'])) {
    	//$object = get_post($pageParams->query_vars['page_id']); // sfc: for use with no permalinks
    	$object = get_page_by_path($pageParams->query_vars['pagename']);
    	$objectType = $object->post_type;
    	$objectId = $object->ID;
    //} elseif (isset($pageParams->query_vars['cat_id'])) { // sfc: for use with no permalinks
    } elseif (isset($pageParams->query_vars['category_name'])) {
    	//$object = get_category($pageParams->query_vars['cat_id']); // sfc: for use with no permalinks
    	$object = get_category_by_slug($pageParams->query_vars['category_name']);
    	$objectType = 'category';
    	$objectId = $object->term_id;
    }

    Hope this helps somebody. Better yet, I hope this helps the developer. I really like this plug in and hope to see it supported. I also use a similar plugin called Role Scoper but find that, while powerful, it’s also very complicated. I really like the straightforward nature of User Access Manager for those sites that just need some simple access management.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Plugin: User Access Manager] problem with redirects’ is closed to new replies.