In some cases it is necessary to redirect request from your phpList installation to a website in your cms.
PHPList does provide custom pages, but sometimes it is easier to redirect request to your cms, because in a cms for example, you already have your template and all your informations. You don’t have to write the html code again, you just create a new article and your done. So for all that were looking for an easy way, there is none!
You have to edit php code! Let’s start.
First of all, the confirmation page:
Open the file /lists/index.php at line: 531 (remove the dots in the html tags)
$res = '
$res .= $data["header"];
$res .= '<.h1>'.$info.'<./h1>';
$res .= $html;
$res .= "<.P>".$GLOBALS["PoweredBy"].'';
$res .= $data["footer"];
return $res;
Modify it by adding the following:
$res = '
/*$res .= $data["header"];
$res .= '<.h1>'.$info.'<./h1>';
$res .= $html;
$res .= "<.P>".$GLOBALS["PoweredBy"].'<./p>';
$res .= $data["footer"];
*/
$res = header("Location: http://www.spamcollect.com/confirmation_page");
return $res;
Next step is the unsubscription page.
Goto line: 589
There you see the following:
if ($userid) {
$res .= '<.h1>...'.$GLOBALS["strUnsubscribeDone"] ."<./h1><.P>";
$res .= $GLOBALS["PoweredBy"].'<./p>';
$res .= $pagedata["footer"];
return $res;
}
Change it to:
if ($userid)
/*$res .= '<.h1>...'.$GLOBALS["strUnsubscribeDone"] ."<./h1><.P>";
$res .= $GLOBALS["PoweredBy"].'<./p>';
$res .= $pagedata["footer"];*/
$res = header("Location: http://www.spamcollect.com/unsubscribe_confirm");
return $res;
The last one is the subscribe page. To change that, you’ll have to open the file lists/admin/subscribelib2.php.
Goto line: 288
if ($subscribepagedata["thankyoupage"]) {
$thankyoupage = $subscribepagedata["thankyoupage"];
} else {
$thankyoupage = '<.h3>'.$strThanks.'<./h3>'. $strEmailConfirmation;
}
Modify it so it looks like:
if ($subscribepagedata["thankyoupage"]) {
//$thankyoupage = $subscribepagedata["thankyoupage"];
header('Location: http://www.spamcollect.com/subscription_successful');
} else {
//$thankyoupage = '<.h3>'.$strThanks.'<./h3>'. $strEmailConfirmation;
header("Location: http://www.spamcollect.com/subscription_successful");
}
Now you’re done and your users won’t see any pages from phplist.
hello,
nice hack!
some days ago tincan published a new phplist version (2.10.5)
now the file /lists/index.php changed, can you please give a uptade to it, so i can use your hack with the newsest version?
thank you very much.
robert
I’m trying to redirect the user to the homepage instead of the default confirmation page after they’ve subscribed to a newsletter. Edited index.php as such:
/*
$res = ”.$GLOBALS[“strConfirmTitle”].”;
$res .= $data[“header”];
$res .= ”.$info.”;
$res .= $html;
$res .= “”.$GLOBALS[“PoweredBy”].”;
$res .= $data[“footer”];
*/
$res = header(’Location: http:/www.vpsupply.biz’);
return $res;
}
However, instead of redirecting I get a parse error for line 582 which is $res=header…
FYI I’m not using a CMS, but this hack should work anyway right?
Hey,
maybe it’s the wrong url, but instead of
$res = header(’Location: http:/www.vpsupply.biz’);
return $res;
i guess, you could also use:
return header(“Location: http://www.vpsupply.biz“);
You should use ” instead of ‘
Tell me if that helped you!
HAHA!
Double quotes, that did the trick.
Very quick response, great hack and much thanks!
Indeed a GREAT hack 😀
Thanks
Hello there! Just what I’ve been looking for. However, the index.php file has changed, as Robert had asked before me, is there any plan to update the procedure on implementing the hack? And, when I was attempting the hack, when I add, header(’Location: http://www.myaddress.com/subscription_successful’); the // in the http:// commented the website address out, haha. Not sure if there is a work around. Thanks for your help and hard work.
Hey Ken,
just use double quotas and it should work!
I’ll have a look on the new version of phplist in the next days.
So check for updates. 😉
Thanks for the great advice here! I am trying to put a phplist into a dynamic showcase site. I have most of it working.
On the confirmation page. I see you show what code to hack to change this, but what should the code be for the page that its directed to.
For example if I point them to, http://www.example.com/confirmation_page, what do I need to have on that page to make it work?
Regards,
Shaun
Hey Shaun,
the answer is really easy: “whatever you like”!
In my case, we redirected the confirmation page to page generated by our content managment system.
Thanks for your fast reply, I love the idea of a blog to help you remember how you did things. I know I have so many times come to that point where I am like…I know I did this before..how did I do that?
I’m a bit confused here. So this is what I have now. I have a zen-cart showcase site, then i have a list folder inside the same area where all the zc site files are and two different databases. So say I want the person to go to http://www.example.com/index.php?main_page=confirmation isn’t there something that needs to be in that page to notify the database for phplist to know that the user has confirmed? Right now, I am using a meta refresh, but I don’t really like that.
Hi Shaun,
it’s in your hand what you put on that site. All the technical part is done in the part before the redirect.
Hello,
I know next to nothing about php code. Could you please help me out with this error?
I modified the code in /lists/index.php to become this:
/*
$res = ”.$GLOBALS[“strConfirmTitle”].”;
$res .= $data[“header”];
$res .= ”.$info.”;
$res .= $html;
$res .= “”.$GLOBALS[“PoweredBy”].”;
$res .= $data[“footer”];
*/
$res = header(â€ÂLocation: http://www.mysite.com/thankyou.htmâ€Â);
return $res;
However, I keep getting this error message:
Parse error: syntax error, unexpected ‘:’ in /lists/index.php on line 540
And “line 540” is:
$res = header(â€ÂLocation: http://www.mysite.com/thankyou.htmâ€Â);
I must have made a mistake somewhere, but I just don’t know what it is. Could you please help me out here? Thank you so much!
Rick
Hi Rick,
normally I need to have the lines before and after the error.
In your case, please check if line 539 ends with a ; not a :
Hi again!
Thank you for your quick response. The following are more lines before and after the error:
} else {
logEvent(“Request for confirmation for invalid user ID: “.substr($_GET[“uid”],0,150));
$html .= ‘Error: ‘.$GLOBALS[“strUserNotFound”];
$info = $GLOBALS[“strConfirmFailInfo”];
}
$data = PageData($id);
if (isset($data[‘language_file’]) && is_file(dirname(__FILE__).’/texts/’.$data[‘language_file’])) {
@include dirname(__FILE__).’/texts/’.$data[‘language_file’];
}
/*
$res = ”.$GLOBALS[“strConfirmTitle”].”;
$res .= $data[“header”];
$res .= ”.$info.”;
$res .= $html;
$res .= “”.$GLOBALS[“PoweredBy”].”;
$res .= $data[“footer”];
*/
$res = header(â€ÂLocation: http://www.mysite.com/thankyou.htmâ€Â);
return $res;
}
function unsubscribePage($id) {
$pagedata = pageData($id);
if (isset($pagedata[‘language_file’]) && is_file(dirname(__FILE__).’/texts/’.$pagedata[‘language_file’])) {
@include dirname(__FILE__).’/texts/’.$pagedata[‘language_file’];
}
global $tables;
$res = $pagedata[“header”];
$res .= ”.$GLOBALS[“strUnsubscribeTitle”].”;
Did I actually put the modified code in a wrong place?
Thanks again for your kind help!
Rick
Admin,
Brilliant work, Got a couple of questions, maybe you could help with.
First I am a designer and am in the process of creating several video tutorials for phplist as well as wordpress. May I create a tutorial showing this code implemented? Now for the second question, Once I have completed the tutorial can you critique it for me?
Also, do you have any ideas on redirecting the user preferences page to a regular web page.
Warmest Regards,
Magickwolf
Hi Magickwolf,
go ahead. I would appreciate it, if you could add a link to this side on your website.
I’ll have to look in the code to see where the user prefs are implemented. Stay tuned.
This will take some days, cause I’m not at my computer during xmas…
No Worries, I haven’t started on it yet but will begin shortly after the holidays. I will definitely direct a link to your site.
MERRY CHRISTMAS, HAPPY YULE (TO ALL)
May your days be blessed with good fortune, happy memories, great times and LOVE.
Warmest Regards,
MagickWolf
Hi,
Hope this thread is still active.
I’m using PHPList version 2.10.5. Everything seems to work fine except for the confirmation page. It just keeps on going to the normal PHPList confirmation page. My code are as follows:
$res = “”;
//$res .= $data[“header”];
//$res .= ”.$info.”;
//$res .= $html;
//$res .= “”.$GLOBALS[“PoweredBy”].”;
//$res .= $data[“footer”];*/
$res = header(“Location: http://www.virtualincomeisreal.com/confirmation“);
return $res;
Help would be really appreciated.
Thanks
Hi Elmer,
this thread is still open. Maybe you could copy more code!?
Which line number did you change?
All is working well now. I made a silly mistake not worth mentioning. Thanks for this thread.
Hi –
Tried this, didn’t work the first time. Got parse error.
Where are you suppose to use the double quotes? In the url area?
Thanks!
In which line do you get the parse error?
Please ensure that all header(… use double quotes.
Hmm, tried your code, sorted the parse error out, but now i am redirected to the normal thank you page.
i am using phplist 2.10.5
my code:
…
$data = PageData($id);
if (isset($data[‘language_file’]) && is_file(dirname(__FILE__).’/texts/’.$data[‘language_file’])) {
@include dirname(__FILE__).’/texts/’.$data[‘language_file’];
}
$res = ”.$GLOBALS[“strConfirmTitle”].”;
$res .= $data[“header”];
$res .= ”.$info.”;
$res .= $html;
$res .= “”.$GLOBALS[“PoweredBy”].”;
$res .= $data[“footer”];
$res = header(“Location: http://xxx.xxx.xxx.xxx/news/lists/“);
return $res;
}
function unsubscribePage($id) {
…
I am runnning this beast on a xampp based installation and would try to use this stuff as adresstool for an exhibition (like an webterminal). After successfull checkin users should be redirected to the initial startingpage. Unfortunately this doesn’t work…
Any help would be appriciated
Mike
first of all, thanks a lot for the work and sharing it!
i ould love to get this working… but i´m facing soem problems and can only second ken who wrote this:
http://www.spamcollect.com/archives/19#comment-27
any chance on solving the comment problem shining light on the new index file?
thanks in advance all the best!
sorry… my “and” sign didnt show up in the previous post.
hi everybody,
just a quick one… i finally got the redirect working in the new version of PHP list. Just alter the file /index.php instead of lists/index.php in the way it is described above and it should work…
Hey guys,
I tried the mod but no luck with it. Instead of going to “salescopyquickfix.com/domination.html” (the site I want to redirect to), it goes to “http://salescopyquickfix.com/mailinglist/?p=subscribe”, which is the default thank you page.
However, the thank you page is blank when I use the mod. It appears fine if I don’t.
I don’t know if this has got anything to do with it, but my form is customized and put up on my site instead of the default subscription page.
Thanks.
Hi There…
I’m experiencing the exact same dificulties as described above by Andre.
After altering the subscribelib2.php document. I’m being redirectied too a blank page with ‘?p=subscribeâ€Â,’ added to the url after signing up for the newsletter.
I also have a customized subscription page on my site and i tried juggling the configuration a little but no luck so far…
Would really appreciate any help.
P.S. kuddo’s for your efforts.
Has anyone gotten the mod to work on the new version of phplist 2.10.5? Its still going go the default customization page for me.
Great Hack… Can’t get it to work! Using 2.10.5 like others… Implemented and am just getting the standard confirm page. Ideas??
$data = PageData($id);
if (isset($data[‘language_file’]) && is_file(dirname(__FILE__).’/texts/’.$data[‘language_file’])) {
@include dirname(__FILE__).’/texts/’.$data[‘language_file’];
}
/*
$res = ”.$GLOBALS[“strConfirmTitle”].”;
$res .= $data[“header”];
$res .= ”.$info.”;
$res .= $html;
$res .= “”.$GLOBALS[“PoweredBy”].”;
$res .= $data[“footer”];
*/
$res = header(“Location: http://www.XXX.com/confirmation.html“);
return $res;
}
function unsubscribePage($id) {
$pagedata = pageData($id);
if (isset($pagedata[‘language_file’]) && is_file(dirname(__FILE__).’/texts/’.$pagedata[‘language_file’])) {
@include dirname(__FILE__).’/texts/’.$pagedata[‘language_file’];
}
I had the same problems with blank page and with parse error for : like described on forum.
I’ve managed to fix that all.
First at index.php
$res = header(‘Location:http://www.mysite.com/desirepage.htm‘);
if you put ” it won’t work since all right from // will go as comment
so you must use ‘ instead of ”
Second at subscribelib2.php
header(‘Location: http://www.mysite.com‘);
the same think, use ‘ instead of “”
and you put this line 2 times.
I don’t know why it sees // like start of a comment after http: when we use “” but important thing is that it works with ‘.
I need heeeeeeeelp!
I can’t get it working… I have tried the simple quotes (‘) and the double quotes(“) solution, tried many times from scratch, but I always get the standard pages.
I have the latest version of phplist (2.10.5) and spent so many hours on it…
I already have created all my custom pages (subscribe, unsubscribe and confirmation pages). Is there anything to add in them?
In one of my numerous tries, when I clicked on the subscribe button, it did not show the confirmation page and instead cleared the fields in the subscibe form.
I am going so crazy right now !!!
Can the problem also be that the custom pages are not in the same folder (same domain though)?
I now have everything working great… appart from the unsubscribe! Also, can this hack be extended to the preferences edit?
Don’t know if this thread is still being monitored….but thought I would try. The hack is awesome and works like a charm. Thank you so much for posting it! Any references to such questions in the PHPList forum are answered rather obliquely. The ONLY problem I’m experiencing is with the unsubscribe page. It looks like it is attempting to work, but nothing happens and I’m wondering if I am misunderstanding the process.
My first thought is that I don’t have all of the code needed in the unsubscribe form to post the data (or remove it) from the database.
Any idea what actual coding is needed for the unsubscribe form page to work? When I was testing it out with the “untainted” version, it appeared to have 2 parts. One was just a form to enter an email address which populated the second page (by selecting a continue button). Not quite sure why someone would need to go through two steps to unsubscribe, so the form I am using is the second (final?) one in the process.
Any input would be TREMENDOUSLY appreciated!
Has anyone figured out the 2.10.5 yet? I am absolutely stumped and have searched through the forums several times to no avail.
OK, I figured out the solution.
Does anyone know where the “Change Preferences” code would be to redirect this page also?
Can you post your solution for the rest of us? Thanks a bunch.
i’m novice with php.
I’m trying to use any lightbox clone for phplist without success.
now i’m using modalbox and i should like to load the “thankyoupage”
into the modal window.
this is my code:
button to start the modalbox with inside the form to subscribe:
the form inside the modal window:
var fieldstocheck = new Array();
fieldnames = new Array();
function checkform() {
for (i=0;i
Email:
addFieldToCheck(“email”,”Email Address”);
now if i click on the button,the “thankyou page” will load outside the modalbox.
there is no way editing the html code, i should change the php code.
any suggestion?
thanks in advance and sorry for my english
Im using 2.10.5 version and I managed to hacked (redirect to my own preferred page) thank you page and confirmation page. (I left unsubscribe page by default).
I suggest you guys try these.
For customized thank you page:
go to admin then open subscribelib2.php line 298. the original code is:
if ($subscribepagedata[“thankyoupage”]) {
$thankyoupage = $subscribepagedata[“thankyoupage”];
} else {
$thankyoupage = ”.$strThanks.”. $strEmailConfirmation;
change it to:
if ($subscribepagedata[“thankyoupage”]) {
$thankyoupage = $subscribepagedata[“thankyoupage”];
header(“Location: http://www.yourdomain/your_thankyou_page.php“);
} else {
$thankyoupage = ”.$strThanks.”. $strEmailConfirmation;
For customized confirmation page (page after user click confirmation in their email):
go to lists then open index.php line 576. the original code is:
$res = ”.$GLOBALS[“strConfirmTitle”].”;
$res .= $data[“header”];
$res .= ”.$info.”;
$res .= $html;
$res .= “”.$GLOBALS[“PoweredBy”].”;
$res .= $data[“footer”];
return $res;
change it to:
$res = ”.$GLOBALS[“strConfirmTitle”].”;
header(“Location: http://www.yourdomain/your_confirm_page.php“);
$res .= $data[“header”];
$res .= ”.$info.”;
$res .= $html;
$res .= “”.$GLOBALS[“PoweredBy”].”;
$res .= $data[“footer”];
return $res;
and you’re done! I do all these steps, and it work great with no hiccup; all emails sent properly.
hope this helps.
I just went through this exercise for the new version 2.10.9. Here’s the update with proper line numbers for this version:
For the custom landing page after the user clicks the confirmation link in the confirmation email:
In /lists/index.php, comment out the following lines (576-581):
$res = ”.$GLOBALS[“strConfirmTitle”].”;
$res .= $data[“header”];
$res .= ”.$info.”;
$res .= $html;
$res .= “”.$GLOBALS[“PoweredBy”].”;
$res .= $data[“footer”];
In order to comment out the lines, add a /* at the beginning of line 576, and a */ after line 581, to make it look like this:
/* $res = ”.$GLOBALS[“strConfirmTitle”].”;
$res .= $data[“header”];
$res .= ”.$info.”;
$res .= $html;
$res .= “”.$GLOBALS[“PoweredBy”].”;
$res .= $data[“footer”];
*/
Add in the following line immediately after these lines:
$res = header(‘Location: http://www.domain.com/thanks-for-confirming-your-subscription.html‘);
(Assuming your custom landing page is http://www.domain.com/thanks-for-confirming-your-subscription.html).
(Also note the single quotation marks. If you use double quotation marks, it will not work, because everything after the // in the URL will be treated as a comment.)
For the custom landing page after the subscribe form is filled out:
In /lists/admin/subscribelib2.php, comment out lines 299 and 301, and add lines immediately after these lines, so the section now looks like this:
# personalise the thank you page
if ($subscribepagedata[“thankyoupage”]) {
// $thankyoupage = $subscribepagedata[“thankyoupage”];
header(‘Location: http://www.domain.com/thanks-for-subscribing‘);
} else {
// $thankyoupage = ”.$strThanks.”. $strEmailConfirmation;
header(‘Location: http://www.domain.com/thanks-for-subscribing‘);
}
(Note that you are adding the same line twice, once after line 299 and once after line 301. Also note again the single quotes.)
I’ll post again once I get the code for the unsubscribe and preference pages figured out.
hi jason!
I´m really looking forward to customize my unsubscribe page! did you have the chance to find out how this is going to work? unfortunately I can´t figure it out on my own…
thanks!
I checked this out eight months back and am attempting it again. I have adjusted the php codes being referred to above with no problems. I am having a difficult time figuring out where to get the code to put into my custom .html unsubscribe page.
Customize Unsubscribe page in php version 2.10.9
index.php line 654
if ($userid)
$res .= ”.$GLOBALS[“strUnsubscribeDone”] .””;
When you make it like showed here..
if ($userid)
//$res .= ”.$GLOBALS[“strUnsubscribeDone”] .””;
$res = header(“Location: http://youtdomain/youragoner“);
then on submit it redirects to your page.
Only i could not get it to work with an own page form.
I made an own form page(get) and made it direct to a page with this code:
Statet here http://packetcloud.net/tag/phplist/
works good for me with a redirection to my thanx page in it.
hope this can help someone and thx for the scripts here.
Great hack- much appreciated! Just what I was looking for 🙂 I can not figure out why phplist makes the customizing of these pages so difficult!? Thanks again for your work, and for maintaining this thread.
Hello,
Thanks for the information that you have shared here. I have tried to customize the pages as you have said. But for the thank you page , I have redirected page to my website. And confirmation emails are not going now. So, what should be the problem according to you? Please help me. Thanks.
Thank you for the excellent tutorial.
I’m left with one problem, when a person enters an invalid email address, phplist keeps redirecting me to the default “Please enter a valid email address” page, how can i modify that?
The link i’m getting is:
http://mydomain/newsletter/?p=subscribe&id=3
Hi All
Great thread with some great comments.
I have successfully managed to customise all pages except the preferences page.
Every time the user clicks on the “update preferences” link in the email – they get take to the default “request your personal location” page, even though the email link correctly adds the UID to the end of the URL. It just doesn’t seem to want to recognise it!
I have tried adjusting the Admin>Config>”Edit URL for preferences” but no good. I have also tried various PHP hacks found when searching the (very messy) forum.
If anyone has managed to customise the preferences page so that the user can change their details on a page within your own site design – I would dearly love to know how!
As Jason says, I don’t know why it is so difficult to customise PHPList so it can be integrated easily!
Looking forward to any helpful replies!
Cheers
Sol
Problem Child: Here’s what I did to solve this problem:
Find these lines in subscribelib2.php:
} elseif ((isset($_POST[“subscribe”]) || isset($_POST[“update”])) && !is_email($_POST[“email”])) {
$msg = ”.$strEnterEmail.”;
Replace with:
} elseif ((isset($_POST[“subscribe”]) || isset($_POST[“update”])) && !is_email($_POST[“email”])) {
// $msg = ”.$strEnterEmail.”;
header(“Location: http://yoursite.com/invalidemail.html“);
Use whatever URL you want to redirect it to. I just inserted a variable in the URL (index.php?valid=false) then added this line of code to the custom subscribe page:
<?php
$p = $_GET["valid"];
if ($p == "false") {
print "Please enter a valid e-mail address.”;
?>
Hope this helps!
Jeff
Thanks so much! I have my own thank you page now displaying on OTO below the thank you. Very cool!
Any idea how to add an autoresponder function to php list?