Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: ListMessenger (or PHPlist) integration – plugin?


peterverkooijen
Participant

@peterverkooijen

This works:

function synchro_mailinglist($user_id, $password, $meta) {
global $bp, $wpdb;

$email = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE ID='$user_id'");

$fullname = $meta[field_1];
$space = strpos( $fullname, ' ' );

$company = $meta[field_2];

if ( false === $space ) {
$firstname = $fullname;
$lastname = '';
} else {
$firstname = substr( $fullname, 0, $space );
$lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
}

$firstname = nameize($firstname);
$lastname = nameize($lastname);

...

$wpdb->query("INSERT mailingusers SET users_id='$user_id', group_id='1', signup_date= UNIX_TIMESTAMP(), firstname= '$firstname', lastname= '$lastname', email_address = '$email' ");
$wpdb->query("INSERT mailingcdata SET cdata_id=NULL, user_id='$user_id', cfield_id='1', value='$company'");

}
add_action( 'wpmu_activate_user', 'synchro_mailinglist', 10, 3);

I used it as part of this function. This should work other mailinglist scripts as well, just change the table and field names.

I don’t understand why $user_email didn’t work. I had to pull the user_email from the database. Is there a cleaner way?

Skip to toolbar