latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

client needs mail merge info from S2 database

Home Forums Community Forum client needs mail merge info from S2 database

This topic contains 3 replies, has 3 voices. Last updated by  Raam Dev 4 years, 2 months ago.

Topic Author Topic
Posted: Wednesday Oct 17th, 2012 at 5:02 pm #28750
lisa carr
Username: pageadmin

Hi-

i have a client who i designed a website for using the S2 members plugin – they have been using microsoft access for 10 years and no one really knows how to use it well – i tried to bring them into this century by having an online database w/ S2 – which tracked the 800 or so existing members and new ones as well and connected to their paypal acct. and a mailing list through mailchimp BUT they now want to send out a mailer via usps and for several months have not been updating the access file – unfortunately when they download the csv from S2, it is all screwy and i’m sure even more so in access.
Is there any way of somehow just getting the people’s name & address via a csv w/out any of the other fields? And also having it be able to be readable in access or perhaps excel?

Or any other thoughts…;-) thanks!

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Thursday Oct 18th, 2012 at 8:04 am #28821

Hi Lisa.

You could modify the export tool to export the CSV the way you want it. Here’s a hack that may help: http://www.primothemes.com/forums/viewtopic.php?f=4&t=14093

I recommend that you work on a copy of the file, and put it in the must-use plugins folder /wp-content/mu-plugins/ so it’s not overwritten on update.

I hope that helps. :)

Posted: Monday Oct 22nd, 2012 at 11:42 am #29268
lisa carr
Username: pageadmin

Hi Christian,

you posted to modify the exports-in.inc.php file with this:
——————————–
function get_s2member_custom_fields($user_id = ”) {
$return = array();
$user = get_user_option(‘s2member_custom_fields’, $user_id);

foreach ((array)json_decode($GLOBALS[‘WS_PLUGIN__’][‘s2member’][‘o’][‘custom_reg_fields’], true) as $field) {
if (isset($user[$field[‘id’]])) {
$return[$field[‘id’]][‘label’] = $field[‘label’];

if (empty($field[‘options’]))
$return[$field[‘id’]][‘value’] = $user[$field[‘id’]];
else {
$field[‘options’] = strpos($field[‘options’], “\n”) ? explode(“\n”, $field[‘options’]) : (array)$field[‘options’];
foreach ($field[‘options’] as $option) {
$option = explode(‘|’, $option);
$options[$option[0]] = $option[1];
}
foreach ((array)$user[$field[‘id’]] as $choice)
$return[$field[‘id’]][‘options’][$choice] = $options[$choice];
}
}
}
return $return;
}

—————————-

Keeping in mind that i do not know php…..when i opened the file up, there were 290 lines of code. I am at a loss as to where i would add this without messing things up!
Where exactly does it go?

here’s what my file looks like:

= 1) ? $start : 1; /* Must be 1 or higher. */
$sql_s = ($start === 1) ? 0 : $start; /* 1 should be 0. */
/**/
$export = “”; /* Initialize the export file variable. */
/**/
$s2map = array ( /* Map s2Member fields. */
“custom” => $wpdb->prefix . “s2member_custom”,/**/
“subscr_id” => $wpdb->prefix . “s2member_subscr_id”,/**/
“subscr_gateway” => $wpdb->prefix . “s2member_subscr_gateway”,/**/
“auto_eot_time” => $wpdb->prefix . “s2member_auto_eot_time”,/**/
“last_payment_time” => $wpdb->prefix . “s2member_last_payment_time”,/**/
“paid_registration_times” => $wpdb->prefix . “s2member_paid_registration_times”,/**/
“custom_fields” => $wpdb->prefix . “s2member_custom_fields”);
/**/
if (is_array ($_users = $wpdb->get_results (“SELECT `” . $wpdb->users . “`.`ID` FROM `” . $wpdb->users . “`, `” . $wpdb->usermeta . “` WHERE `” . $wpdb->users . “`.`ID` = `” . $wpdb->usermeta . “`.`user_id` AND `” . $wpdb->usermeta . “`.`meta_key` = ‘” . esc_sql ($wpdb->prefix . “capabilities”) . “‘ LIMIT ” . $sql_s . “, 250″)))
{
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ())
$export .= ‘”ID”,”Username”,”First Name”,”Last Name”,”Display Name”,”Email”,”Website”,”Role”,”Custom Capabilities”,”Registration Date”,”First Payment Date”,”Last Payment Date”,”Auto-EOT Date”,”Custom Value”,”Paid Subscr. ID”,”Paid Subscr. Gateway”‘ . “\n”;
else /* Otherwise, we use the standardized format for exportation.*/
$export .= ‘”ID”,”Username”,”Password”,”First Name”,”Last Name”,”Display Name”,”Email”,”Website”,”Role”,”Custom Capabilities”,”Registration Date”,”First Payment Date”,”Last Payment Date”,”Auto-EOT Date”,”Custom Value”,”Paid Subscr. ID”,”Paid Subscr. Gateway”‘ . “\n”;
/**/
foreach ($_users as $_user) /* Go through each User/Member in this result set. */
{
if (is_object ($user = new WP_User ($_user->ID)) && $user->ID)
{
$custom_capabilities = “”; /* Reset each time. */
/**/
foreach ($user->allcaps as $cap => $cap_enabled)
if (preg_match (“/^access_s2member_ccap_/”, $cap))
if ($cap = preg_replace (“/^access_s2member_ccap_/”, “”, $cap))
$custom_capabilities .= “,” . $cap;
/**/
$custom_capabilities = trim ($custom_capabilities, “,”);
/**/
$custom = (isset ($user->$s2map[“custom”])) ? $user->$s2map[“custom”] : “”;
$subscr_id = (isset ($user->$s2map[“subscr_id”])) ? $user->$s2map[“subscr_id”] : “”;
$subscr_gateway = (isset ($user->$s2map[“subscr_gateway”])) ? $user->$s2map[“subscr_gateway”] : “”;
/**/
$auto_eot_time = (isset ($user->$s2map[“auto_eot_time”])) ? $user->$s2map[“auto_eot_time”] : “”;
$last_payment_time = (isset ($user->$s2map[“last_payment_time”])) ? $user->$s2map[“last_payment_time”] : “”;
$paid_registration_times = (isset ($user->$s2map[“paid_registration_times”])) ? $user->$s2map[“paid_registration_times”] : “”;
$custom_fields = (isset ($user->$s2map[“custom_fields”]) && is_array ($user->$s2map[“custom_fields”])) ? $user->$s2map[“custom_fields”] : array ();
/**/
$paid_registration_date = ($paid_registration_times[“level”]) ? date (“m/d/Y”, $paid_registration_times[“level”]) : “”;
$paid_registration_times = (is_array ($paid_registration_times) && !empty ($paid_registration_times)) ? serialize ($paid_registration_times) : “”;
$registration_date = ($user->user_registered) ? date (“m/d/Y”, strtotime ($user->user_registered)) : “”;
$last_payment_date = ($last_payment_time) ? date (“m/d/Y”, $last_payment_time) : “”;
$auto_eot_date = ($auto_eot_time) ? date (“m/d/Y”, $auto_eot_time) : “”;
/**/
ksort ($custom_fields); /* Make sure Custom Fields are always in the same order.
This provides clarity/uniformity in the export file. */
/**/
if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && !is_main_site ())
{
if ($format === “readable”) /* Human readable format; easier for some. */
{
$line = ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->ID) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->user_login) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->first_name) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->last_name) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->display_name) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->user_email) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->user_url) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq (reset ($user->roles)) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($custom_capabilities) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($registration_date) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($paid_registration_date) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($last_payment_date) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($auto_eot_date) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($custom) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($subscr_id) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($subscr_gateway) . ‘”,’;
/**/
foreach ($custom_fields as $custom_field_var => $custom_field_value)
{
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($custom_field_var) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq /* Implode array? */
(implode (“|”, (array)$custom_field_value)) . ‘”,’;
}
}
else /* Otherwise, we can just use the default re-importation format. */
{
$line = ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->ID) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->user_login) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->first_name) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->last_name) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->display_name) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->user_email) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->user_url) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq (reset ($user->roles)) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($custom_capabilities) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($registration_date) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($paid_registration_times) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($last_payment_date) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($auto_eot_date) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($custom) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($subscr_id) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($subscr_gateway) . ‘”,’;
/**/
foreach ($custom_fields as $custom_field_var => $custom_field_value)
{
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($custom_field_var) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq /* Serialize? */
(maybe_serialize ($custom_field_value)) . ‘”,’;
}
}
}
else /* Otherwise, we use the standardized formats for exportation.*/
{
if ($format === “readable”) /* Human readable format; easier for some. */
{
$line = ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->ID) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->user_login) . ‘”,’;
$line .= ‘””,’; /* The Password field is left blank on export. */
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->first_name) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->last_name) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->display_name) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->user_email) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->user_url) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq (reset ($user->roles)) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($custom_capabilities) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($registration_date) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($paid_registration_date) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($last_payment_date) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($auto_eot_date) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($custom) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($subscr_id) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($subscr_gateway) . ‘”,’;
/**/
foreach ($custom_fields as $custom_field_var => $custom_field_value)
{
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($custom_field_var) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq /* Implode array? */
(implode (“|”, (array)$custom_field_value)) . ‘”,’;
}
}
else /* Otherwise, we can just use the default re-importation format. */
{
$line = ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->ID) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->user_login) . ‘”,’;
$line .= ‘””,’; /* The Password field is left blank on export. */
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->first_name) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->last_name) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->display_name) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->user_email) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($user->user_url) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq (reset ($user->roles)) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($custom_capabilities) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($registration_date) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($paid_registration_times) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($last_payment_date) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($auto_eot_date) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($custom) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($subscr_id) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($subscr_gateway) . ‘”,’;
/**/
foreach ($custom_fields as $custom_field_var => $custom_field_value)
{
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq ($custom_field_var) . ‘”,’;
$line .= ‘”‘ . c_ws_plugin__s2member_utils_strings::esc_dq /* Serialize? */
(maybe_serialize ($custom_field_value)) . ‘”,’;
}
}
}
/**/
$export .= trim ($line, ” \r\n\t\x0B,”) . “\n”;
}
}
}
/**/
status_header (200); /* 200 OK status header. */
/**/
header (“Content-Encoding:”);
header (“Accept-Ranges: none”);
header (“Content-Type: text/csv; charset=utf-8”);
header (“Content-Length: ” . strlen ($export));
header (“Expires: ” . gmdate (“D, d M Y H:i:s”, strtotime (“-1 week”)) . ” GMT”);
header (“Last-Modified: ” . gmdate (“D, d M Y H:i:s”) . ” GMT”);
header (“Cache-Control: no-cache, must-revalidate, max-age=0”);
header (“Cache-Control: post-check=0, pre-check=0”, false);
header (“Pragma: no-cache”);
/**/
header (‘Content-Disposition: attachment; filename=”export-‘ . $start . ‘-‘ . ($start + 249) . ‘.csv”‘);
/**/
exit ($export); /* Exportation file. */
}
}
/**
* Handles the exportation of options.
*
* @package s2Member\Exports
* @since 110815
*
* @return null Or exits script execution after issuing file download prompt with TXT file.
*/
public static function export_ops ()
{
if (!empty ($_GET[“ws_plugin__s2member_pro_export_ops”]) && ($nonce = $_GET[“ws_plugin__s2member_pro_export_ops”]) && wp_verify_nonce ($nonce, “ws-plugin–s2member-pro-export-ops”) && current_user_can (“create_users”))
{
$export = serialize (c_ws_plugin__s2member_pro_utils_ops::op_replace ($GLOBALS[“WS_PLUGIN__”][“s2member”][“o”]));
/**/
@set_time_limit (0) . @ini_set (“memory_limit”, apply_filters (“admin_memory_limit”, WP_MAX_MEMORY_LIMIT));
@ini_set (“zlib.output_compression”, 0) . eval (‘while (@ob_end_clean ());’);
/**/
status_header (200); /* 200 OK status header. */
/**/
header (“Content-Encoding:”);
header (“Accept-Ranges: none”);
header (“Content-Type: text/plain; charset=utf-8”);
header (“Content-Length: ” . strlen ($export));
header (“Expires: ” . gmdate (“D, d M Y H:i:s”, strtotime (“-1 week”)) . ” GMT”);
header (“Last-Modified: ” . gmdate (“D, d M Y H:i:s”) . ” GMT”);
header (“Cache-Control: no-cache, must-revalidate, max-age=0”);
header (“Cache-Control: post-check=0, pre-check=0”, false);
header (“Pragma: no-cache”);
/**/
header (‘Content-Disposition: attachment; filename=”export.s2e”‘);
/**/
exit ($export); /* Exportation file. */
}
}
}
}
?>

Posted: Monday Oct 22nd, 2012 at 2:36 pm #29306
Raam Dev
Username: Raam
Staff Member

Hi Lisa,

This modification requires knowledge of PHP; it’s not just a copy/paste thing. If you’re not comfortable with PHP, you may want to post a job on jobs.wordpress.net to find a PHP programmer who can make this modification.

Viewing 3 replies - 1 through 3 (of 3 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.