2 yabba Nov 23, 2007 10:12

Thanks Yabba - but I'm a bit lost as to how to do this. I've never coded a plugin before. And don't know how to get the plugin to be called by the message form.
A little bit more help needed please!
Thanks,
Na3
Here's an example of a plugin that should work for you, note, it's totaly untested
<?php
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
class yourplugin_plugin extends Plugin
{
var $name = 'Mailing List';
var $code = 'mail_list';
var $priority = 50;
var $version = 1;
var $author = 'Your name';
var $group = 'Your group name';
var $help_url = 'http://yourdomain.com/';
function PluginInnit()
{
$this->short_desc = 'short description for your plugin';
$this->long_desc = 'long description for your plugin';
return $this;
}
/**
* add your field to the message form
*
* @param mixed $params
*/
function DisplayMessageFormFieldset( $params )
{
$params['Form']->checkbox( $this->get_class_id().'_subscribe', true, 'Join mailing list', 'would you like to be added to our mailing list?' );
}
/**
* Add the answer to the email
*
* @param mixed $params
*/
function MessageFormSent( & $params )
{
if( param( $this->get_class_id().'_subscribe', 'boolean' ) )
{ // visitor wishes to be added
$params['message'] .= 'Add me to your mailing list';
}
else
{ // visitor doesn't wish to be added
$params['message'] .= 'Don\'t add me to your mailing list';
}
return $params;
}
}
?>
Important bit :
You need to name the file to match whatever plugin name you choose, so if your plugin is called yourplugin in the code
class yourplugin_plugin extends Plugin
then your file must be named
yourplugin.plugin.php
Obviously you need to upload it to your plugins folder and install it. It will automatically be called at the right moments by the message form and when the message form is submitted
¥
Thanks Yabba.
The code works fine, up until I press send. I got the following errors (both ticking the checkbox, and without):
Warning: Cannot modify header information - headers already sent by (output started at /home//public_html/sal/plugins/_mailinglist.plugin.php:1) in /home//public_html/sal/inc/_misc/_misc.funcs.php on line 2886
Warning: Cannot modify header information - headers already sent by (output started at /home//public_html/sal/plugins/_mailinglist.plugin.php:1) in /home//public_html/sal/inc/_misc/_misc.funcs.php on line 2887
Warning: Cannot modify header information - headers already sent by (output started at /home//public_html/sal/plugins/_mailinglist.plugin.php:1) in /home//public_html/sal/inc/_misc/_misc.funcs.php on line 2888
Warning: Cannot modify header information - headers already sent by (output started at /home//public_html/sal/plugins/_mailinglist.plugin.php:1) in /home//public_html/sal/inc/_misc/_misc.funcs.php on line 2889
Warning: Cannot modify header information - headers already sent by (output started at /home//public_html/sal/plugins/_mailinglist.plugin.php:1) in /home//public_html/sal/inc/_misc/_misc.funcs.php on line 2984
Warning: Cannot modify header information - headers already sent by (output started at /home/public_html/sal/plugins/_mailinglist.plugin.php:1) in /home//public_html/sal/inc/_misc/_misc.funcs.php on line 2987
And I'm getting this error in the backend:
Warning: Cannot modify header information - headers already sent by (output started at /home/public_html/sal/plugins/_mailinglist.plugin.php:1) in /home//public_html/sal/inc/VIEW/_menutop.php on line 39
Oh, I lie. The errors do appear, but the email does actually come through...
Warning: Cannot modify header information - headers already sent by (output started at /home//public_html/sal/plugins/_mailinglist.plugin.php:1
Open the file in notepad and check for any whitespace/blank lines before the first <?php at the top of the file ;)
¥
I checked the file, and there was one space before the <?php at the top. I removed it, but I'm still getting errors.
There will probably be one space after the closing ?> also. I tested this and it works without errors when you are done with the whitespace.
Only yesterday did I wrote about this in the docs: [url=http://manual.b2evolution.net/FAQ_:_After_Installation#I_get_this_error:_.22Warning:_Cannot_modify_header_information_-_headers_already_sent_by_.28output_started_at_....22] I get this error: "Warning: Cannot modify header information - headers already sent by (output started at ..."[/url].
Good luck
Thanks Afwas and Yabba! That fixed it and all works fine now. Thanks again for all your help!
Hi Afwas you sent me over here as an answer to http://forums.b2evolution.net/viewtopic.php?t=13247 with my question on how to popup all users emails at once instead of clicking each email icon to get their email. Ive dont all this and installed the plugin. Now Im not even really sure what its suppose to do or what I should see!
I was not an answer but an idea. If your users contact you through the contact form, they now have an option to join the newsletter. That's on the email you get from them (I want to join, I do not want to join).
You still need to setup the newsletter yourself or mailinglist or whatever it is you want.
Good luck
OH ok. So maybe I should be requestion something some where on how to grab all emails at once?
I don't know how may you have, but they are in the database.
With your email client (Thunderbird is preferred, but Outlook will do) you can setup a group 'Bloggers' and write a newsletter every month. You send that to (ALWAYS in th BCC field) the group and everybody receives the newsletter.
New bloggers and others will contact you through email and you add them or not.
Good luck
One more thing. I made a tester account and I didnt see anywhere that asked about registering for my mailing list. What should I be seeing and where after installing the plugin?
(sorry m really novice at all this and just trying to figure it all out!)
thank you!
THe most robust way is to code a plugin that hooks into the following events :
¥