<?php
//this one only updates the email, you need to create a webhook that only triggers on "mail changed"
include("wp-config.php");
$conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db(DB_NAME, $conn);
$stringData .= $sql = "UPDATE wp_users SET user_email = '".$_POST["data"]["new_email"]."' WHERE user_email = '".$_POST["data"]["old_email"]."'";
$query = mysql_query($sql);
?>
<?php
//this one is more tricky hehe, it updates all the data, but as I'm using several custom fields the code added up! Is the same principle, though.
include("wp-config.php");
$conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db(DB_NAME, $conn);
//select user with the email that matches the notice from mailchimp
$sql = "SELECT * FROM wp_users WHERE user_email = '".$_POST["data"]["email"]."'";
$query = mysql_query($sql);
$row = mysql_fetch_assoc($query);
//update first name
$sql = "SELECT umeta_id FROM wp_usermeta WHERE user_id = ".$row["ID"]." AND meta_key = 'first_name'";
$query = mysql_query($sql);
$umetaId = mysql_result($query, 0);
$stringData .= $sql = "UPDATE wp_usermeta
SET
meta_value = '".$_POST["data"]["merges"]["MERGE1"]."'
WHERE umeta_id = '".$umetaId."'";
$query = mysql_query($sql);
//update last name
$sql = "SELECT umeta_id FROM wp_usermeta WHERE user_id = ".$row["ID"]." AND meta_key = 'last_name'";
$query = mysql_query($sql);
$umetaId = mysql_result($query, 0);
$stringData .= $sql = "UPDATE wp_usermeta
SET
meta_value = '".$_POST["data"]["merges"]["MERGE2"]."'
WHERE umeta_id = '".$umetaId."'";
$query = mysql_query($sql);
//select the metadata (in my case I'm using a lot of merge fields)
$sql = "SELECT * FROM wp_usermeta WHERE user_id = ".$row["ID"]." AND meta_key = 'wp_s2member_custom_fields'";
$query = mysql_query($sql);
$row = mysql_fetch_assoc($query);
$data["merge3"] = $_POST["data"]["merges"]["MERGE3"];
$data["merge4"] = $_POST["data"]["merges"]["MERGE4"];
$data["merge10"] = $_POST["data"]["merges"]["MERGE10"];
$data["merge5"] = $_POST["data"]["merges"]["MMERGE5"];
$data["merge6"] = $_POST["data"]["merges"]["MMERGE6"];
$data["merge7"] = $_POST["data"]["merges"]["MMERGE7"];
$data["merge8"] = $_POST["data"]["merges"]["MMERGE8"];
$data["merge9"] = $_POST["data"]["merges"]["MERGE9"];
$data["merge13"] = $_POST["data"]["merges"]["MMERGE13"];
$data = serialize($data);
//update that particular meta row
$stringData .= $sql = "UPDATE wp_usermeta
SET
meta_value = '".$data."'
WHERE umeta_id = '".$row["umeta_id"]."'";
$query = mysql_query($sql);
?>
Statistics: Posted by Leinad — July 5th, 2011, 4:52 pm
Statistics: Posted by Cristián Lávaque — July 3rd, 2011, 8:38 pm
Statistics: Posted by BobTabor — July 3rd, 2011, 5:09 pm
<?php
include("wp-config.php");
$conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db(DB_NAME, $conn);
foreach($_POST as $key => $value)
{
if(is_array($value))
{
foreach($value as $keyValue => $val)
{
if($keyValue == "email")
{
$email = $val;
}
}
}
}
$sql = "DELETE FROM wp_users WHERE user_email = '$email'";
$query = mysql_query($sql);
?>
Statistics: Posted by Leinad — July 3rd, 2011, 4:55 pm
Statistics: Posted by Leinad — June 25th, 2011, 11:32 am
Statistics: Posted by BobTabor — June 24th, 2011, 10:20 pm
Statistics: Posted by Leinad — June 24th, 2011, 8:52 pm