• Resolved benjudy

    (@benjudy)


    Great plugin! One issue: I have many pages, and I created two versions of each. One for ‘visitors’ and one for anyone signed-in to the site. Currently it seems I must set the redirect for every role, and on every page, so people who are signed in get sent to the signed-in pages! Very tedious. Is there a better approach?

    All of my pages follow the same naming convention. Could the plugin be updated to accept a variable or set a rule? That way I could turn on redirect for a category of pages, and I would only have to do this once instead of for every page. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author AAM Plugin

    (@vasyltech)

    Hi benjudy,

    Thank you for great question. Yes there is much easier, undocumented way however you would have to create a small callback function and you should have AAM Plus Package.

    Step 1.
    Create two page categories (e.g. Unregistered, Registered) and group your pages accordingly.

    Step 2.
    Switch to the Manage Default Settings (fourth tab on the User/Role panel) and go to Posts & Pages. Click Manage Access for Pages and for the Frontend REDIRECT instead of valid URL or page ID, enter valid PHP callback function. This will define redirect rule for all pages to all users and visitors on your website. All pages will inherit this rule unless overwritten for any user, role or visitor. For more info about AAM access settings inheritance check this article.

    Step 3.
    Create your callback function that checks if user is logged in and currently is trying to browse page in Unregistered category. If so, then redirect to the page in Registered category with the same name. Do vise versa for unregistered user.

    Hopefully this is helpful.
    Regards,
    Vasyl

    Thread Starter benjudy

    (@benjudy)

    Hi Vasyl,

    Thanks so much for your reply! I think it makes sense.

    However, I am having trouble in step 2, when entering my PHP function in the REDIRECT to Valid URL or Page ID field. After applying this, I get an error message when I try to view a page.

    It seems that whatever I add is not being interpreted as PHP code. The function I added is visible in the ‘view source’ HTML of the page.

    Is there some other setting I must enable, so AAM will allow entering PHP in the REDIRECT field? Thanks!

    Plugin Author AAM Plugin

    (@vasyltech)

    benjudy,

    It has to be a valid PHP callback function like MyClassName::myRedirectFunc or myCustomRedirect func. Do not insert any PHP code as AAM does not evaluate any PHP code.

    Also note, that whatever callback function you’ve defined, it has to be loaded before WordPress call ‘init’ hook.

    Regards,
    Vasyl

    Thread Starter benjudy

    (@benjudy)

    Got it! It is working now. I was trying to make it too complicated. And as you can tell, I’m not much of a programmer. But your help was excellent, thanks so much for taking time to reply. Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Redirect rules or variables’ is closed to new replies.