type; } if ( in_array($node->type, $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){ $node = node_load( array( 'uid' => $user->uid, 'type' => $type->type ), NULL, true ); if ($node){ foreach( content_fields( NULL, $type->type ) as $field_name => $field_values ){ if ( $field_values['type_name'] == $type->type ){ $node = node_build_content($node, false, true); $value = isset( $node->{$field_name}[0]['format'] ) ? check_markup( $node->{$field_name}[0]['value'], $node->{$field_name}[0]['format'], false ) : check_plain( $node->{$field_name}[0]['value'] ); $out[$type->type .'_'. $field_name] = $value; } } } } } return $out; }