type == nodeprofile_get_types()) ) { if( ($q = _mailchimp_get_api_object()) && ($account = user_load(array('uid' => $node->uid))) ) { foreach ( (array)$q->lists() as $key => $list ) { if ( _mailchimp_is_subscribed( $list['id'], $account->mail, $q ) ) { $merge_vars = _mailchimp_load_user_list_mergevars( $account->uid, $list['id'], $q->listMergeVars($list['id']) ); _mailchimp_update_user( $list, $account->mail, $merge_vars, $q ); } } } } break; } } /** * Implementation of hook_mailchimp_merge_keys */ function mailchimp_nodeprofile_mailchimp_merge_keys() { $out = array( 0 => '' ); if ( function_exists( 'nodeprofile_get_types' ) ) { foreach(nodeprofile_get_types() as $type){ foreach(content_fields(NULL, $type->type) as $field_name => $field_values){ if ($field_values['type_name'] == $type->type){ $name = node_get_types('name', $type->type); $out[$type->type .'_'. $field_name] = $name .': '. $field_values['widget']['label']; } } } } return $out; } /** * Implementation of hook_mailchimp_merge_values */ function mailchimp_nodeprofile_mailchimp_merge_values( $user ) { $out = array(); $out = (array)$user; $out = array_merge( $out, _mailchimp_nodeprofile_get_fields( $user ) ); return $out; } /** * Get Node Profile fields for the given user */ function _mailchimp_nodeprofile_get_fields( $user ) { $out = array(); if ( function_exists( 'nodeprofile_get_types' ) ) { foreach(nodeprofile_get_types() as $type){ $profile = node_load(array('uid' => $user->uid, 'type' => $type->type), NULL, true); $profile = node_build_content($profile, false, true); foreach(content_fields(NULL, $type->type) as $field_name => $field_values){ if ($field_values['type_name'] == $type){ $out[$type->type .'_'. $field_name] = $profile->$$field_name[0]['view']; } } } } return $out; }