Integrating phpBB and phpList

I’ve been procrastinating on a project because I was waiting for someone to finally make a modification for phpBB that would automatically subscribe a user to a phpList newsletter. I couldn’t wait anymore so I just went ahead and did some tinkering around. Please be warned that this is a rough hack and isn’t validated by the phpBB mod team.

This hack works for phpList 2.10.10 and phpBB 3.0.5.

Download this file and rename it to functions_phplist.php. If you edit the file with notepad or any text editor, you would find this part:

	$database_host = "localhost";
	$database_name = "database";
	$database_user = "username";
	$database_password = "password";
	$table_prefix = "phplist_";
	$usertable_prefix = "phplist_user_";

Fill those in with your phpList credentials which you could get from your phpList config.php file. I didn’t want to include the phpList file as there might be global variables that could be overwritten. That’s the only thing you have to alter in that file. After editing it, upload it to the /includes folder inside your phpBB folder.

Now to integrate that function into phpBB core, you have to edit the /includes/ucp/ucp_register.php file in your phpBB folder. Look for these lines:

	$message = $message . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.$phpEx") . '">', '</a>');
	trigger_error($message);

and insert the following lines before it:

	//Include phplist functions
	include($phpbb_root_path . 'includes/functions_phplist.' . $phpEx);
	//Subscribe user to phplist
	$phplist_user_id = phplist_subscribeuser($data['email'], 1);

Notice the “1″ in that last line? Change that to the id of the newsletter you want your users to be subscribed to. You could get that from your phpList admin page. After editing, upload it to your server overwriting the original ucp_register.php file. And that’s it!

Once a user registers in your forums, they will be automatically subscribed to your newsletter as well. But take note that this is very limited. For one, it won’t send a welcome message to the user’s email. Also, the subscribing process happens during registration. If you have validation of email addresses in your boards and you want the subscribing process to occur once a user validates his/her email address, you will have to tinker with a different file instead of ucp_register.php. Maybe ucp_activate.php, I’m not sure since I didn’t tinker with anything else. Also, since I didn’t provide the user with an unsubscribe option in their profile, they can only unsubscribe to the newsletter via phpList’s unsubscribe page.

Now, if you already have users in your boards and want to import them to your phpList newsletter, save this file as a php file and edit these lines to reflect the paths to your phpBB and phpList config files.

require("/path/to/phplist/config/config.php");

and

require("/path/to/phpbb/config.php");

Then find this line

phplist_subscribeuser($row['user_email'], 1);

and replace “1″ with the id of the newsletter you want your users to be subscribed to. Upload the file to your server and access it via your browser and wait for the script to finish running. When I imported 16,000 users it roughly took me less than 5 minutes to finish.

That’s it. Feel free to tinker it to your heart’s content. I just wanted to share this because making this work gave me a headache.

tags: , ,

marikitORG

This is the random musings and thoughts of a 20-something year old Filipina girl who goes by the name of Teckie though sometimes she's more commonly known as Tec. She loves anime, manga, video games, movies and romance novels. She's obsessing over Jensen Ackles and wishes that one of these days that they go off and marry... or at least have some hot sex together. Currently lurking in the Supernatural and Glee fandom. But since she's a flighty and ecclectic little girl, you might find her in other fandoms too.
adoptions, cliques and rings tag archive

Other places: flavors.me livejournal flixster facebook shelfari music
and if you have any other questions ask away!

Search:

Twitter

follow me at twitter

Wishlistr

God of War III
for the PS3
Buy or view this item
Final Fantasy Versus XIII
for the PS3
Buy or view this item
Final Fantasy XIII
for the PS3
Buy or view this item
Batman: Arkham Asylum
for the PS3
Buy or view this item
Aladdin (Disney Special Platinum Edition)
Buy or view this item

more from my wishlist at wishlistr

Tumblr

Hide and Seek World Champs
07 Apr, 2009 05:10PM


Hide and Seek World Champs

see my tumblelog at tumblr