Download & Extend

Hook system for pulling data in data during sync

Project:PHPlist Integration Module
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:paulbeaney
Status:reviewed & tested by the community

Issue Summary

I just wanted to say that I've modified this module a tiny bit to add a hook system at the end of user sync. This enables me to pull in more data from a content profile without much direct modification of the phplist module.

I've attached a patch to add what I'm talking about, if you are interested.
Here is an example of the hook I'm using, which saves attributes from the content profile module.

<?php
/**
* Implementation of hook_phplist_sync_user().
*/
function ew_phplist_sync_user($user, $phplistid) {
 
$node = content_profile_load('profile', $user->uid);
  if (
$node) {
    foreach (array(
'first_name', 'last_name', 'market') as $field) {
     
$cck = "field_$field";

      if(
is_array($node->$cck)){
       
$arr = array_values($node->$cck);
        if (
$arr[0]['value']) {
         
_phplist_update_attribute($field, 'textline', $arr[0]['value'], $phplistid);
        }
      }
    }
  }

 
_phplist_update_attribute('language', 'textline', user_preferred_language($user)->language, $phplistid);
}
?>
AttachmentSize
phplist_hook.patch464 bytes

Comments

#1

Assigned to:Anonymous» paulbeaney

Hi pertheusual,

Thanks for this contribution. You're not the only person who has asked for Content Profile synchronisation. I guess this could do with some expanding to allow the same (or more) configuration options as the existing Profile features i.e. select which profile fields are mapped to which PHPlist attributes.

Will pursue this one further...

Regards,

- Paul

#2

Subscribe, thx!

#3

Status:active» reviewed & tested by the community

Nice!

This patch applies not only to Content Profile but allows any module to make its own additions to sync.

The main patch failed when applying against 6.x-1.x-dev.

Here's a new one that works...

AttachmentSize
phplist_hook-D6.patch 521 bytes
nobody click here