Not logged in. · Lost password · Registration disabled

All posts by lyndonjohn (2)

topic: Automatically Add Subscriber's Email to List Address and Unsubscribe link(Solved!) (After user registration, their emails will automatically add to List of Addresses in PN and Delete(Unsubscribe) their account as well as in PN)  in the forum: Suggestions and Wishes / Anregungen und Wünsche
Avatar
lyndonjohn #1
Member since Apr 2011 · 2 posts
Group memberships: Mitglieder
Show profile · Link to this post
Subject: Automatically Add Subscriber's Email to List Address and Unsubscribe link(Solved!)
I posted this under Suggestions and Wishes because I think this is the closest topic I guess.

Im sure some of you here are waiting for this answer on how to automatically add registered users to PN and a working Unsubscribe Link. Well here it is!

This is quite tricky because we have to deal with the codes. But don't worry, just follow this step by step guide and I will get you through it.

A. Automatically Add Subscriber's Email to List Address
You need to know first your:
database name
mysql host
database username
database password
*You these to to create connection

1. Lets create .php page, lets call it autoadd.php (This page will add registered users to PN)

<?php
// Create Connection
$db_name="name of your database"; //edit this according to your database name
$connection=mysql_connect("your msql host","database username"," database password") or die("I Couldn't connect");
$db=mysql_select_db($db_name,$connection) or die("I Couldn't select your database");
$table="wp_post_notification_emails"; // Table name
$table1="wp_post_notification_cats"; // Table name

$sqlx = "INSERT INTO $table (email_addr, gets_mail, last_modified, date_subscribed)
values ('$user_email', '1', NOW(), NOW())";
mysql_query($sqlx);

$sqlget = "SELECT id,email_addr FROM wp_post_notification_emails WHERE email_addr = '$user_email'";
$result = mysql_query($sqlget);
$row = mysql_fetch_assoc($result);

$ID = $row['id'];

$sql1 = "INSERT INTO $table1 (id) values ('$ID')";
mysql_query($sql1);
?>

Now save this file as autoadd.php and save/upload it just inside your root folder, just inside the folder where you installed your wordpress.

2. Open your wp-login.php which is located in your root folder, or just download that file using filezilla or your favorite fpt tool and open the file in notepad or wordpad. Look for this code:
wp_new_user_notification( $user_id, $user_pass );

(Ctrl+F for fast search) Once you've located that code, insert this line just below the first code.
require_once 'autoadd.php';

Final:
wp_new_user_notification( $user_id, $user_pass );
require_once 'autoadd.php';

Save wp-login.php and upload it to your root folder(delete your old wp-login.php or overwrite it).
Now, if someone will register to your site his/her email will automatically add to PN. Try it and check the List of Addresses of PN.

B. Unsubscribe Link
You need to know first your:
database name
mysql host
database username
database password
*You these to to create connection

1. Create unsubscribe page. Copy/Paste this code in your notepad or wordpad:
<?php
// Create Connection
$db_name="name of your database"; //edit this according to your database name
$connection=mysql_connect("your msql host","database username"," database password") or die("I Couldn't connect");
$db=mysql_select_db($db_name,$connection) or die("I Couldn't select your database");
$table="wp_post_notification_emails"; // Table name
$table1="wp_post_notification_cats"; // Table name
$table2="wp_users"; // Table name

$code = $_GET['code'];
$e_mail = $_GET['addr'];

//Delete user data from wp_users table
$sqlUsers = "DELETE FROM $table2 WHERE user_email='$e_mail'";
mysql_query($sqlUsers);

//Get $table data to get its id to match the id in $table1
$sqlGet = "SELECT * FROM $table WHERE email_addr='$e_mail'";
$resultGet = mysql_query($sqlGet);
$rowGet = mysql_fetch_assoc($resultGet);

$userID = $rowGet['id'];

//Delete data from wp_post_notification_cats table
$sqlCats = "DELECTE FROM $table1 WHERE id='$userID'";
mysql_query($sqlCats);

//Delete data from wp_post_notification_emails table
$sqlEmails = "DELETE FROM $table WHERE act_code='$code'";
mysql_query($sqlEmails);

header("Location: http://name of your site/index.php/");
?>

Now save as unsubscribe.php and upload it to your root folder.

3. The Link. Open or download email_template.html(the template of your notification that is being sent through mail) which is located in root folder/wp-content/plugins/post-notification/en_US/

Find this code:
<a href="@@conf_url">@@conf_url</a><br />

and replace it with this:
<a href="http://name of your site/unsubscribe.php@@conf_url/">@@conf_url</a><br />

Save it and upload it again to where it came from.
Thats it! Were done!
Questions? Just contact me: ljpvmms09@gmail.com
topic: Automatically Add Subscriber's Email to List Addresses  in the forum: Questions / Fragen
Avatar
lyndonjohn #2
Member since Apr 2011 · 2 posts
Group memberships: Mitglieder
Show profile · Link to this post
Subject: Automatically Add Subscriber's Email to List Addresses
Is it possible to automatically add the subscriber's email address to List of Addresses or to database? Because it is really time consuming to manually add each subscriber's email under "Manage Addresses". If we can solve this problem, Post Notification would be perfect.  :-)
Close Smaller – Larger + Reply to this post:
Special characters:
Special queries
Go to forum