IGNORE the above. The method above will only yield the results of the database BEFORE the update. This correct method is to use the hook:
ws_plugin__s2member_during_handle_profile_modifications
Example code below: (this code is put in any new file in the directory: /wp-content/mu-plugins/)
######## SAMPLE CODE #########
### What does eet doo?
### IT:
### - Grabs the user ID for the current user
### - Then it connects to the WP database and searchers for their user meta data
### - Subsequently, it strips the specific meta data it needs by de-serializing the WP Data into a php-friendly array
### - Finally, it connects to an alternate database and inserts the new data
### ----- the final step is just an example of how to use the NEW user modified data,
### ------ you can update a database instead of creating a new entry like I did in the example,
### ------ but hey...it's just an example.... =D
############################
add_action("ws_plugin__s2member_during_handle_profile_modifications", "MY_EFFIN_FUNCTION");
function MY_EFFIN_FUNCTION($vars = array()){
global $conn, $conn_wp; //retrieve global variables defined outside the function
$agentID = $vars['current_user']->data->ID;
if($conn_wp){
$dbConnection2 = mysql_select_db("myDatabase1", $conn_wp);
if($dbConnection2){
$sqlUD = "select meta_value from myTable1 where user_id='" . $agentID . "' and meta_key='wp_s2member_custom_fields'";
$resultsUD = mysql_query($sqlUD, $conn_wp);
if($resultsUD){
while ($rowUD = mysql_fetch_array($resultsUD)){
$UD_array = unserialize($rowUD['meta_value']);
//retrieve phone number and normalize (strip dashes and parenthesis)
$agentNumber = $UD_array['phone_number']; $agentNumber = str_replace("-","",$agentNumber);
$agentNumber = str_replace("(","",$agentNumber); $agentNumber = str_replace(")","",$agentNumber);
}
}
$resultUI = mysql_query("select user_email from wp_users where ID='" . $agentID . "'", $conn_wp);
if($resultUI){
while ($rowUI = mysql_fetch_array($resultUI)){
$agentEmail = $rowUI['user_email'];
}
}
}
}
if($conn){
mysql_select_db("myDatabase2", $conn);
$sql = "insert into myTable2(agentNumber,agentEmail) values ('" . $agentNumber . "','" . $agentEmail . "')";
$result = mysql_query($sql, $conn);
}
}
Keep in mind that the code above utilizes the OLD method for MYSQL database queries. I just use it to type up a super quick example. It uses the mysql_query extension…. Use of this extension is STRONGLY discouraged. Instead, the MySQLi or PDO_MySQL extension should be used. But, I’m not here to teach MySql… so go google it. =P