Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Elon Report Posted August 8, 2023 Posted August 8, 2023 (edited) I am on the hosted platform, but no access to email support yet. I am using only the following code in a custom php block. header("Location: https://myazurebox/id=". $_COOKIE["ips4_member_id"]); When I call this block, nothing happens. I can see the cookies are there. If I add the exit command: header("Location: https://myazurebox?id=". $_COOKIE["ips4_member_id"]); exit(); I receive a generic error when I try to save the block. Sorry! The page you requested does not existError code: 1S160/2 Edited August 8, 2023 by MartinLawrence removed private info
Randy Calvert Posted August 8, 2023 Posted August 8, 2023 Blocks are parsed in the body. In order for the header() function to execute, it must be done before any output is sent. So I don’t think you can actually do redirects within blocks… instead, I believe you might want to do this within your term with template logic. Someone else can keep me honest on this however as I’m not a coder. I just do system administration. 🙂
Solution opentype Posted August 8, 2023 Solution Posted August 8, 2023 7 minutes ago, Randy Calvert said: I believe you might want to do this within your term with template logic. A template redirect looks like this: {{\IPS\Output::i()->redirect('https://server.com/something.htm');}}
Elon Report Posted August 8, 2023 Author Posted August 8, 2023 3 hours ago, opentype said: A template redirect looks like this: {{\IPS\Output::i()->redirect('https://server.com/something.htm');}} Thank you. I made a new page with just this on it and it worked great. Thanks! How would I go about appending a cookie to that? . $_COOKIE["ips4_member_id"]');}} Comes out as this after redirection. ="%20.%20$_COOKIE["ips4_member_id"]
opentype Posted August 8, 2023 Posted August 8, 2023 Haven’t tested it. Might just be the space around the period character. When in doubt you can create the redirect target in a separate line. {{$target="https://test.com/".$something;}} {{\IPS\Output::i()->redirect($target);}} Should work.
Nathan Explosion Posted August 8, 2023 Posted August 8, 2023 {{\IPS\Output::i()->redirect('https://server.com/something.htm&id='.\IPS\Member::loggedIn()->member_id);}} Potential problem - block caching.
Recommended Posts