• Resolved jerrystewart99

    (@jerrystewart99)


    I have ‘MailChimp for WordPress’ and ‘MailChimp User Sync’ installed.
    All working almost perfectly, except that users are added to MC without a ‘group’ (interest group?)
    I can see my ‘interests’ in the MCforWP ‘General Settings’ page
    I can’t see a way of associating a user with a MC interest group.

    Does anyone have any ideas?

    I’m ok with adding code snippets to a child theme if necessary, but I’m a newbie on that track so please be gentle with me ??

    Thanks in anticipation, Jerry

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Lap

    (@lapzor)

    Hi,

    Take a look at https://github.com/ibericode/mc4wp-snippets/blob/master/add-ons/user-sync/groupings.php

    Hope that helps. If you have any questions, please let us know!

    Thread Starter jerrystewart99

    (@jerrystewart99)

    Well that seems to have done the trick… after figuring out how to do that ?? .. used a home-made plugin in the end.. great fun.

    and thank you heaps for the link.. that is much appreciated.

    I don’t suppose you have any idea how to locate the mailchimp group-id programatically do you.. I currently have it hardcoded.

    cheers, Jerry

    Plugin Contributor Lap

    (@lapzor)

    While it might be possible to do that, you would need additional custom code which is beyond the scope of our support. I would recommend contacting other developers via a service like Codable.

    Hope that helps. If you have any questions, please let us know!

    Thread Starter jerrystewart99

    (@jerrystewart99)

    Hi Lap,

    Thanks for your reply. I understand that is beyond the scope of support here.
    After a bit of investigation and digging I have managed to get that all sorted too. I’m happy to share if anyone else has this issue.

    -Jerry

    Hey. I am trying to do exactly same. How did you manage to find out mailchimp group-id?

    Thread Starter jerrystewart99

    (@jerrystewart99)

    the classes of interest (no pun intended) are
    MC4WP_MailChimp
    MC4WP_MailChimp_List
    MC4WP_MailChimp_Interest_Category
    if you find the relevant files you can inspect the methods and attributes you need.

    Here is a code snippet..

    /**
    * Get the list with the required name (case insensitive)
    *
    * @param $mailchimp MC4WP_MailChimp
    * @return MC4WP_MailChimp_List
    */
    function get_mailchimp_list( $mailchimp, $list_name ) {

    $lists = $mailchimp->get_lists();
    foreach( $lists as $list ) {
    if( strcasecmp( $list->name, $list_name ) == 0 ) {
    return $list;
    }
    }

    log_message( ‘ERROR: No list found = ‘ . $list_name );
    return null;
    }

    /**
    * Get the interest category with the required name (case insensitive)
    *
    * @param $list MC4WP_MailChimp_List
    * @return MC4WP_MailChimp_Interest_Category
    */
    function get_mailchimp_category( $list, $category_name ) {

    // $category is of type MC4WP_MailChimp_Interest_Category
    foreach( $list->interest_categories as $category ) {
    if ( strcasecmp( $category->name, $category_name ) == 0 )
    return $category;
    }

    log_message( ‘ERROR: No category found = ‘ . $category_name );
    return null;
    }

    function your_fucntion() {
    $mailchimp = new MC4WP_MailChimp();
    $list = get_mailchimp_list( $mailchimp, ‘your_list_name’ );
    if ( !isset( $list) || $list == null ) {
    return false;
    }

    $category = get_mailchimp_category( $list, ‘your_category_name’ );
    if ( $category == null ) {
    return false;
    }

    // the list id is here! .. etc.
    $list_id = $list->id;

    // do some more interesting stuff….
    }

    hope that helps – Jerry

    Super helpful. Thank you, really appreciate your effort!

    Plugin Contributor Lap

    (@lapzor)

    Thanks for sharing!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘sync WP user to MC interest group’ is closed to new replies.