Nicht angemeldet. · Kennwort vergessen · Registrierung deaktiviert
Forum: Übersicht Suggestions and Wishes / Anregungen und Wünsche RSS
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
Avatar
lyndonjohn #1
Mitglied seit 04/2011 · 2 Beiträge
Gruppenmitgliedschaften: Mitglieder
Profil anzeigen · Link auf diesen Beitrag
Betreff: 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
mt #2
Mitglied seit 07/2011 · 1 Beitrag
Gruppenmitgliedschaften: Mitglieder
Profil anzeigen · Link auf diesen Beitrag
Zitat von lyndonjohn am 28.04.2011, 07:23:
A. Automatically Add Subscriber's Email to List Address
You need to know first your:
database name
mysql host
database username
database password

hi lyndonjohn,

thanks for working on this feature. i really want to add it to my wp, but i'm not really comfortable to put the  username/password in the code.

is it possible to avoid this ? I think the "Export emails" plugin could access mysql without requiring the explicit username/password.

thanks,

mt
Schließen Kleiner – Größer + Auf diesen Beitrag antworten:
Prüfcode: VeriCode Gib bitte das Wort aus dem Bild ins folgende Textfeld ein. (Nur die Buchstaben eingeben, Kleinschreibung ist in Ordnung.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Weitere Zeichen:
Gehe zu Forum