Sync users with this list from User’s profile
-
Hi,
I’ve reading and trying a few things but I haven’t found neither achieved anything.
I need to show a list of checkboxes with the mailchimp lists, more likely groups inside a mailchimp list, in the user’s profile.
But I haven’t be able to sync that fields with mailchimp.
/** add fields – user profile */
add_action( ‘show_user_profile’, ‘extra_user_profile_fields’ );
add_action( ‘edit_user_profile’, ‘extra_user_profile_fields’ );function extra_user_profile_fields( $user ) { ?>
<h3><?php _e(“Extra profile information”, “blank”); ?></h3>
<?php
$user_listas = get_user_meta( $user->ID, ‘_mc4wp_lists’ );$listas = array(
‘531551d340’ => ‘Nuevos usuarios’,
‘642725f77f’ => ‘Info’,
‘e4644c5572’ => ‘Nuevos usuarios 2’
);
?>
<table class=”form-table”>
<?php
foreach( $listas as $id_lista => $nombre_lista ):
$check = “”;
if( array_key_exists( $id_lista, $user_listas[0] ) )
{
$check = “checked”;
}
?>
<tr>
<th><label for=”_mc4wp_lists[<?php echo $id_lista; ?>]”><span><?php echo $nombre_lista; ?></span></label></th>
<td>
<label>
<input name=”_mc4wp_lists[<?php echo $id_lista; ?>]” id=”_mc4wp_lists[<?php echo $id_lista; ?>]” type=”checkbox” value=”<?php echo $id_lista; ?>” <?php echo $check; ?>>
</label>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php }/** save fields – user profile */
add_action( ‘personal_options_update’, ‘save_extra_user_profile_fields’ );
add_action( ‘edit_user_profile_update’, ‘save_extra_user_profile_fields’ );function save_extra_user_profile_fields( $user ) {
if ( !current_user_can( ‘edit_user’, $user->ID ) ) {
return false;
}
update_user_meta( $user->ID, ‘_mc4wp_lists’, $_POST[‘_mc4wp_lists’] );add_filter( ‘mailchimp_sync_user_data’, function( $vars, $user ) {
$vars[‘INTERESTS’] = isset( $_POST[‘_mc4wp_lists’] ) ? $_POST[‘_mc4wp_lists’] : array();
return $vars;
});}
In addition to that, is there a way to catch the lists and groups inside lists from mailchimp dinamically??
Is there any of this things in the premium version of the plugin??
Thanks for your help.
- The topic ‘Sync users with this list from User’s profile’ is closed to new replies.