Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted August 8, 20231 yr 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, 20231 yr by MartinLawrence removed private info
August 8, 20231 yr 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. 🙂
August 8, 20231 yr Solution 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');}}
August 8, 20231 yr Author 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"]
August 8, 20231 yr 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.
August 8, 20231 yr {{\IPS\Output::i()->redirect('https://server.com/something.htm&id='.\IPS\Member::loggedIn()->member_id);}} Potential problem - block caching.