How to integrate WordPress 2.0 and PHPlist 2.10.2

Has I promised last month, in this post I will explain how to integrate WordPress 2.0 and PHPList 2.10.2.. It’s not the perfect marriage, but definitely it works. Forget all the plugins. You don’t need them.

1. Let’s start by the most obvious, if you don’t have yet WP 2.0 installed, please install it.

2. In the same folder where you installed WP 2.0, create a folder called “lists” or “newsletter”.

3. Install PHPList 2.10.2 in this folder. This “newsletter” or “lists” folder should be the folder with all the files from PHPList.

Newsletter tree


4. Now it’s the time, to create a subscription form which will send the subscription email to the PHPList database. Let’s imagine that you are using kubrick template, the default template at WP 2.0. Create a new php page, call it "news.php", save it on the default template folder and paste it the following code.

<!– newsletter subscribe below here –>

<script language="Javascript" type="text/javascript">

var fieldstocheck = new Array();

fieldnames = new Array();

function checkform() {

for (i=0;i<fieldstocheck.length;i++) {

if (eval("document.subscribeform.elements[‘"+fieldstocheck[i]+"’].value") == "") {

alert("Please enter your "+fieldnames[i]);

eval("document.subscribeform.elements[‘"+fieldstocheck[i]+"’].focus()");

return false;

}
}

return true;

}

function addFieldToCheck(value,name) {

fieldstocheck[fieldstocheck.length] = value;

fieldnames[fieldnames.length] = name;

}
</script>

<form method="post" action="http://your_domain/your_phplist_folder/?p=subscribe" name="subscribeform" target = "_self"> 
<input type="text" name="email" value = "">

<script language="Javascript" type="text/javascript">addFieldToCheck("email","email address");</script>

<input type="hidden" name="list[2]" value=signup />

<input type=submit name="subscribe" value="Subscribe" onClick="return checkform();">

</form>

Attention you should change “your_domain” and “your_phplist_folder”.

5. At “sidebar.php” from WP 2.0 default template folder and after the searchform add the following code:

<li>

    <?php include (TEMPLATEPATH . ‘/news.php’); ?>

</li>

6. At this point you blog should look like this:
blog
 

7. Now you have to create a new list at PHPList, to receive your blog subscriptions, that you can call “Blog”, for instance.

8. Then you have to create a new subscribe page at PHPList, which will have the same layout and design of a regular page of your blog.

8.1. At the “Title” field you write something like: “WordPress Subscribe Page”;

8.2. Delete all the content of “Intro”,“Header”, “Footer” and “Thank you page” boxes;

8.3. Now open your blog and view his page source, select all the code and copy it to a notepad or a similar program.

8.4. First of all, look for the most important div of the code of this page source, the div where the content of the post is published. In the default template of WP 2.0, it should be the <div class=”entry”> and cut all of the code before this div, including <div class="entry"> and paste it at “Header” box at subscribe page at PHPList.

8.5. Now delete all the text until you find </div> of <div class="entry">, and cut the rest of the code, which should begin with </div> and paste it at “Footer” box at subscribe page at PHPList. You should look for the "postmetadata", and delete it from this box.

8.6. At the “Thank you page” box at subscribe page at PHPList paste something like this “<p>Thank you for subscribing to our newsletters. Your email has been added to our system. You will be e-mailed shortly with a request to confirm your membership. Please make sure to click the link in that message to confirm your subscription.</p>”, which will be text that will be presented to your subscribers after they subscribe your newsletter.

8.7. At “Text for Button” you can leave only “Subscribe”.

8.8. At “HTML Email choice” choose “Don’t offer choice, default to text” or “Don’t offer choice, default to HTML”.

8.9. At “Display Email confirmation” choose “Don’t display email confirmation”.

8.10. And finally check “Blog” list at “Select the lists to offer”.

8.11. Now it’s just “Save and Activate”.

This is all that matters. The rest is just about customizing WordPress template or PHPList.
In case of doubts, please contact me.

WordPressWP 2.0PHPListHOWTONewsletterMailing-lists

  • http://blog.invisivel.net Filipe Correia

    Only one thing missing for it to be the “perfect marriage” 🙂 It would be great to have an option that would make a newsletter post be automatically sent with the blog post’s contents, whenever a new blog post was published.

    I understand Mailing List Plugin is a step closer to doing this, but still, not the entire post content is sent, only a notification that a new post exists on the blog.

    I guess I’ll have to keep looking, or perhaps get my hands dirty too 🙂

  • http://www.shortbusriders.org John Coble

    I had high hopes for this to work, but I was disappointed. This is obviously a hard problem to solve, so I appreciate your effort.

    First of all when I cut/pasted your code the apostrophes (‘) came out as “curly” instead of straight — ‘/news.php’. So I had to figure that out. (It’s in your Javascript code too.) Also, by using the source code of a current blog page, all of the “current” information becomes static. So any updates to my sidebar don’t happen on the subscribe page. I could try to make a new blog page template and strip out the live sidebar content, but it would still have problems. With the subscribe box in the Sidebar there’s no way to unsubscribe or get more information about the list. I gave up and just made the background of my subscribe page match the background of my site.

  • lordjiem

    Header, footer (and others phplist optionnal texts) do not allow php in them. In order to enable php interpretation, you have to modify all the references to “header” and “footer” in /index.php and /admin/subscribelib2.php with a call to the php function ‘eval()’.

    [for example,
    in /admin/subscribelib2.php, instead of
    print $subscribepagedata[“header”];
    put
    print (eval(‘?>’ . $subscribepagedata[“header”] . ‘

  • http://TzPjBXfCTb.com TzPjBXfCTb

    Hi! Very nice site! Thanks you very much! 64rY6qYufyM