Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#121 2008-04-18 13:11:51
Re: [ARCHIVED] Postmaster (0.4.4) -A simple newsletter manager
OK, here comes a long code block. I tweaked the bab_pm_zemcontact_submit
function to enable an existing user to subscribe to another list and I added the ability to unsubscribe from a specific list. (I wasn’t going to post the code because, at the time, it seemed like it was something I wanted but wasn’t needed elsewhere.)
When I designed it I was working under the assumption that the site designer would build pages that add (or subtract) a specific list (or lists). I was accomplishing this by using something like
<txp:zem_contact_secret name="zemUnSubscribe" value="Updates" />
…or…
<txp:zem_contact_secret name="zemUnSubscribe" value="Updates Newsletter SomeOtherList" />
I haven’t done any testing to see if it would work on a single page with multiple options. So, take what you can use and leave the rest. As always, any comments or improvements are greatly appreciated. (I will say that I’m not sure if the errors returned by the function actually do anything. They were a part of the existing code but I don’t think it’s possible to give the user any feedback at this point.) Also, if there is a better way to post this much code let me know…
function bab_pm_zemcontact_submit()
{
global $zem_contact_values;
extract(doSlash($zem_contact_values));
$bab_pm_SubscribersTable = PFX.'bab_pm_subscribers';
// check if this IS a Postmaster zem_submit; if not, return
if (!$zemSubscriberEmail) {
return;
}
else {
// check if the zemDoSubscribe option is included; if so, does it say no? if no, return
if ($zemDoSubscribe) {
if ($zemDoSubscribe == 'No') {
return;
}
}
// check if zemUnSubscribe is included
if ($zemUnSubscribe) {
// if this is a global delete completely remove the subscriber
if ($zemUnSubscribe == 'global_delete') {
$success = safe_delete($bab_pm_SubscribersTable, "subscriberEmail='$zemSubscriberEmail'");
if ($success) {
return;
}
else {
return 'There was an error. Please contact the administrator of this website.';
}
}
else {
// the value of zem_contact_secret wasn't global_delete so
// break up the lists submitted and remove just those from
// the subscriber
$deleteValues = explode(' ', $zemUnSubscribe);
$subscriber = safe_rows("subscriberLists", $bab_pm_SubscribersTable, "subscriberEmail='$zemSubscriberEmail'");
extract($subscriber[0]);
foreach ($deleteValues as $value) {
$value = '/\b'.$value.'\b/';
$subscriberLists = preg_replace($value, '', $subscriberLists);
}
$subscriberLists = trim(str_replace(' ', ' ', $subscriberLists));
if ($subscriberLists == '') {
$success = safe_delete($bab_pm_SubscribersTable, "subscriberEmail='$zemSubscriberEmail'");
}
else {
$success = safe_update($bab_pm_SubscribersTable, "subscriberLists='$subscriberLists'", "subscriberEmail='$zemSubscriberEmail'");
}
if ($success) {
return;
}
else {
return 'There was an error. Please contact the administrator of this website.';
}
}
}
// zemSubscriberAggregate: you can change WHERE you want the aggregated content to end up,
// by changing each instance of $zemSubscriberLists to the correct variable name
$field = bab_pm_preferences('aggregate_field');
$field = '$bab_pm_' . $field;
$$field;
if ($zemSubscriberAggregate) {
$zemSubscriberLists = '';
foreach ($zemSubscriberAggregate as $item) {
$zemSubscriberLists .= $item . ' ';
}
}
// otherwise, enter data into postmaster
// Check to see if the subscriber already exists
// If so, see which list(s) they are subscribed to
$subscriber = safe_rows("subscriberLists", $bab_pm_SubscribersTable, "subscriberEmail='$zemSubscriberEmail'");
if (!$subscriber) {
// This is a new subscriber so add them to the db
$md5 = md5(uniqid(rand(),true));
$create_sql5[] = safe_query("INSERT INTO $bab_pm_SubscribersTable values (NULL,'$zemSubscriberName','$zemSubscriberEmail','$zemSubscriberLists','$zemSubscriberCustom1','$zemSubscriberCustom2','$zemSubscriberCustom3','$zemSubscriberCustom4','$zemSubscriberCustom5','$zemSubscriberCustom6','$zemSubscriberCustom7','$zemSubscriberCustom8','$zemSubscriberCustom9','$zemSubscriberCustom10','','','$md5')");
}
else {
// This is an existing user so append the new list to the subscription
// If the subscriber is already a member of this list do nothing
extract($subscriber[0]);
$searchString = '/\b'.$zemSubscriberLists.'\b/';
if (!preg_match($searchString, $subscriberLists)) {
$zemSubscriberLists = $subscriberLists.' '.$zemSubscriberLists;
$success = safe_update($bab_pm_SubscribersTable, "subscriberLists='$zemSubscriberLists'", "subscriberEmail='$zemSubscriberEmail'");
if ($success === false) {
return "There was an error. Please contact the administrator of this website.";
}
}
}
}
}
Offline
#122 2008-04-18 15:27:50
Re: [ARCHIVED] Postmaster (0.4.4) -A simple newsletter manager
jdykast wrote:
I tweaked the
bab_pm_zemcontact_submit
function to enable an existing user to subscribe to another list and I added the ability to unsubscribe from a specific list.
Thanks jdykast: you da man. That’s a great basis to work off. I just gotta tweak your tweak to either handle non-ZCR checkboxes, or find a way to post a value other than “yes/no” from a ZCR checkbox such that PM knows which list(s) are being unsubscribed.
If I get it going in a way that’s generic enough for others to use I’ll post it back here. Thanks again for the head start!
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#123 2008-04-18 17:35:58
Re: [ARCHIVED] Postmaster (0.4.4) -A simple newsletter manager
Sorry to be so absent from the conversation, folks. Thanks for helping eachother out — hopefully when there’s some downtime I can capture all the good stuff you’ve been working on.
I briefly read but didn’t get into some of your questions, and off the top of my head I think the aggregator can help with some of this.
- Ben
Offline
#124 2008-04-18 22:51:26
Re: [ARCHIVED] Postmaster (0.4.4) -A simple newsletter manager
Hi Ben, et all…
I need to figure out how to do this (use “zemSubcriberCustom2, zemSubcriberCustom1” for the “zemSubscriberName” field) using the latest version (4.4). I have a feeling it’s all about the aggregator, but I’m not that swift.
Help appreciated.
Offline
#125 2008-04-28 20:21:19
Re: [ARCHIVED] Postmaster (0.4.4) -A simple newsletter manager
I have just installed postmaster but am getting the following error messages:
In the subscribers tab
Warning: Missing argument 1 for page_url() in /home/kmtaylor/public_html/newsite/textpattern/publish/taghandlers.php on line 2911
Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/kmtaylor/public_html/newsite/textpattern/lib/txplib_misc.php on line 651
Warning: array_diff() [function.array-diff]: Argument #1 is not an array in /home/kmtaylor/public_html/newsite/textpattern/lib/txplib_misc.php on line 651
Warning: Invalid argument supplied for foreach() in /home/kmtaylor/public_html/newsite/textpattern/lib/txplib_misc.php on line 651
List of subscribers
Warning: Missing argument 1 for page_url() in /home/kmtaylor/public_html/newsite/textpattern/publish/taghandlers.php on line 2911
Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/kmtaylor/public_html/newsite/textpattern/lib/txplib_misc.php on line 651
Warning: array_diff() [function.array-diff]: Argument #1 is not an array in /home/kmtaylor/public_html/newsite/textpattern/lib/txplib_misc.php on line 651
Warning: Invalid argument supplied for foreach() in /home/kmtaylor/public_html/newsite/textpattern/lib/txplib_misc.php on line 651
And List of lists
Warning: Missing argument 1 for page_url() in /home/kmtaylor/public_html/newsite/textpattern/publish/taghandlers.php on line 2911
Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/kmtaylor/public_html/newsite/textpattern/lib/txplib_misc.php on line 651
Warning: array_diff() [function.array-diff]: Argument #1 is not an array in /home/kmtaylor/public_html/newsite/textpattern/lib/txplib_misc.php on line 651
Warning: Invalid argument supplied for foreach() in /home/kmtaylor/public_html/newsite/textpattern/lib/txplib_misc.php on line 651
What is going on? Can anyon help?
Offline
#126 2008-04-28 20:25:21
Re: [ARCHIVED] Postmaster (0.4.4) -A simple newsletter manager
Is your site in Testing/Debug mode?
If I’m not wrong, if you set it to Live, the messages will dissappear.
Anyway, I think youcan ignore them (in the sense they aren’t affecting anything).
Offline
#127 2008-04-28 20:36:43
Re: [ARCHIVED] Postmaster (0.4.4) -A simple newsletter manager
Thank you! I was fairly sure it was something simple. You are a star!
Offline
#128 2008-04-28 21:18:04
Re: [ARCHIVED] Postmaster (0.4.4) -A simple newsletter manager
It’s been noted before that switching the site to “Live” mode makes the error messages go away but doesn’t actually fix anything. I fixed these issues in my install of the plugin and Bloke took it one step better. If you are willing to dig into the plugin code you can fix the cause of the errors and you won’t be greeted with a swarm of error messages if you need to go back to debugging/testing mode.
Offline
#129 2008-05-22 16:10:06
Re: [ARCHIVED] Postmaster (0.4.4) -A simple newsletter manager
Hi I have a problem with the unsubscribe link it’s doesn’t work :(
the unsubscribe form is working great but is 99% not useful,
so I must to make the link to work.
1. I’m sending an HTML emails.
2. <txp:bab_pm_unsubscribe /> vs <txp:bab_pm_unsubscribeLink /> ???
3. in the <txp:bab_pm_unsubscribeLink />‘s page you are saying to use <txp:bab_pm_unsubscribe />
so whay not delete that <txp:bab_pm_unsubscribeLink />‘s help page from your site?
please post here a step by step of how to use the unsubscribe link please :)
and yea this plugin is so great, no need to teach the client how to use a mailinglist program
just mark “yes” and click save when he post a new news article on he’s site.
I’m all set to go with this plugin but not going to use it until the unsubscribe link will work.
thanks ;)
ohh and one more:
how do I change the “from” to be a name I will enter and not the admin’s email address please?
Last edited by THE BLUE DRAGON (2008-05-23 18:50:11)
Offline
#130 2008-05-23 20:23:51
Re: [ARCHIVED] Postmaster (0.4.4) -A simple newsletter manager
I’ve read this whole thread in order to solve my problem but didn’t find the solution yet.
The problem: I can’t manage to get subscribers to be stored in the DB.
I can add subscribers manually, Nice HTML mails are sent when I test it.
So everything is working properly except for the subscription.
I have only one list called “newsletter”.
All plugins are installed properly, just like ZCR and ZCL
This is the form I use for the subscription page:
<txp:zem_contact to=“me@mydomain.nl” >
<txp:zem_contact_email name=“zemSubscriberEmail” label=“Your Email:” />
<txp:zem_contact_secret name=“zemSubscriberLists” value=“newsletter” />
<txp:zem_contact_submit />
</txp:zem_contact>
The form does validate and is been sent normally, after that I get the “mail sent succesfully” page but no subscriber is added to the subscribers list in the PM admin subscribers tab.
Ideas anybody?
Offline
#131 2008-05-23 21:04:52
Re: [ARCHIVED] Postmaster (0.4.4) -A simple newsletter manager
@THE BLUE DRAGON
<txp:bab_pm_unsubscribeLink />
goes on the form that renders your e-mail. Have you put it there? Are you saying that if you click on the unsuscribe link on the received email you won’t get unsubscribed?
Check the Unsubscribe Link on your list on the “Lists” tabs. Does it point to the article where you have put your <txp:bab_pm_unsubscribe />
tag?
@Momomo
I used to have a similar problem with an old version of gbp_permanent_link. Are you using gbp_permanent_link? Do you receive the email notifying about the new suscription?
The form looks fine for me.
But just to try something different, check if something happens when adding a name:
<txp:zem_contact_text name="zemSubscriberName" label="Name" />
@Ben
Are you still there? :)
I currently have this issue with Postmaster + MLP:
http://forum.textpattern.com/viewtopic.php?pid=179442#p179442
Any chance to make PM to be compatible with MLP? (although, if you read my post on the MLP pack, you may agree that the “problem” is on the MLP side, but maybe you can do some magic on the PM side…)
Thanks!
Offline
#132 2008-05-23 21:34:16
Re: [ARCHIVED] Postmaster (0.4.4) -A simple newsletter manager
maniqui wrote:
I used to have a similar problem with an old version of gbp_permanent_link. Are you using gbp_permanent_link? Do you receive the email notifying about the new suscription?
The form looks fine for me.
But just to try something different, check if something happens when adding a name:
<txp:zem_contact_text name="zemSubscriberName" label="Name" />
Hi maniqui,
I’m not using gbp_permanent_link.
I tried it with the line of code you gave, without succes…
This is the email I receive when I try to subscribe myself:
Name: Martijn
Your Email:: test[at]momono.nl
: newsletter
This is not Spam. : ja
These are all the plugins I use:
hak_tinymce
lam_accordion_section
Postmaster
Postmaster Library
zem_contact_lang
zem_contact_reborn
Offline