• i just tried to redirect to an external site (an online petition) on login

    [wpmem_logged_out]<a title="log in to access petition" class=cgoshoa href="/owners/login?redirect_to=https://chng.it/BXtrRnRTLt">log in</a> to[/wpmem_logged_out]

    but it redirects to the user’s wordpress dashboard page instead:-(something my users would be absolutely flummoxed to see)-:

    i know this works, as on this page:
    https://cardinalglen.org//hoa-info/annual-meeting/2022-proxy

    [wpmem_logged_out]<a href="/owners/login?redirect_to=/hoa-info/annual-meeting/2022-proxy"><button>logged in</button></a>[/wpmem_logged_out]

    can i not redirect to an outside url?-{

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter airdrummer

    (@airdrummer)

    interestingly, and less flummoxing, wrapping the external url in single quotes
    href="/owners/login?redirect_to='https://chng.it/BXtrRnRTL'" >
    redirects to the user’s wpmem profile page…reversing the quotes
    href='/owners/login?redirect_to="https://chng.it/BXtrRnRTL"' >
    still redirects to the wordpress dashboard…

    Thread Starter airdrummer

    (@airdrummer)

    definitely something wrong with quote handling…redirecting to local url works:
    https://cardinalglen.org/owners/login?redirect_to=/events/petition-loco-bos-meeting/
    but adding single quotes around local url
    https://cardinalglen.org/owners/login?redirect_to='/events/petition-loco-bos-meeting'
    redirects to dashboard; double quotes
    https://cardinalglen.org/owners/login/?redirect_to="/events/petition-loco-bos-meeting/"
    works as expected, but the reverse is true for an external url (single quotes to profile page, double quotes to dashboard)-:

    Plugin Author Chad Butler

    (@cbutlerjr)

    can i not redirect to an outside url?-{

    Probably not. I’d have to review the specifics, but most of the redirects use wp_safe_redirect() rather than wp_redirect(). The safe redirect doesn’t allow URLs outside the domain.

    Thread Starter airdrummer

    (@airdrummer)

    arglebargle:-\ i can appreciate the sediments;-) but why the difference of profile/dashboard/”/’? just curious…

    Thread Starter airdrummer

    (@airdrummer)

    ah, here’s the ticket: https://developer.ww.wp.xz.cn/reference/hooks/allowed_redirect_hosts/

    now where to put it…

    Plugin Author Chad Butler

    (@cbutlerjr)

    You can use that filter in your theme’s functions.php or you can create a custom plugin file (creating a custom plugin file to house your code snippets that are not design related is a good way to do it so that it’s portable if you change themes).

    Thread Starter airdrummer

    (@airdrummer)

    thanx, did that but still no joy:-\ it’s not a show stopper, i can always redirect wpm login to a local post which is itself redirected to the external url…

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘redirect not always working:-\’ is closed to new replies.