latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Importing users and Mailchimp integration

Home Forums Community Forum Importing users and Mailchimp integration

This topic contains 10 replies, has 3 voices. Last updated by  Andy Burnett 4 years ago.

Topic Author Topic
Posted: Thursday Dec 6th, 2012 at 9:31 am #33706

I couldn’t find any mention of this with a quick search, but apologies if it is covered somewhere.

I just finished putting a couple of custom fields into s2hacks.php using the ‘ws_plugin__s2member_mailchimp_merge_array’ filter, so that they would be merged across to Mailchimp. That’s working if I sign up on the front end, or if I add a user manually (remembering to tick the ‘Process List Servers’ box). But if I import users via a .csv file into s2Member, then although the custom fields get set up correctly in the WP user database, it doesn’t appear to be signing them up to the associated Mailchimp list (with or without the custom fields).

The Mailchimp API stats don’t even show a failed call, so I presume the equivalent of the ‘Process List Servers’ checkbox isn’t ticked when importing from a csv file. Is there a way to include that in the import file, or a hack to get it to process them? It’s going to be quite critical for a number of our clients who send us a list of user details for us to register, and we really don’t want to have to do it twice (once on s2, once on Mailchimp).

Thanks.

List Of Topic Replies

Viewing 10 replies - 1 through 10 (of 10 total)
Author Replies
Author Replies
Posted: Friday Dec 7th, 2012 at 6:36 am #33857

Hi Andy.

The thing is that the import process is already quite resource intensive, processing the list server with each user imported, would make it that much heavier. You could process the list servers with a PHP script and process the users in steps instad of quickly in a row.

Please read this, http://www.s2member.com/forums/topic/s2member-mailchimp-and-ccaps/#post-17078 from where I start talking about [hilite mono]c_ws_plugin__s2member_list_servers::process_list_servers[/hilite], after the code block.

You’d use that in a script and have it process the users in steps, probably reloading the script with the updated offset to process the next batch.

I hope that helps. :)

Posted: Friday Dec 7th, 2012 at 6:48 am #33859

Thanks – I’ll take a look at that and see how we get on. We’re only talking about a few tens of users at a time to import, but we might be doing it on a regular basis (rather than hundreds or thousands once in a blue moon).

Does that principle apply to bulk deletes via the WordPress system too? I’ve noticed quite a discrepancy between the WP list and MC list as we’ve been testing this…

Posted: Friday Dec 7th, 2012 at 7:14 am #33862

Regarding the list processing on import, I couldn’t find any filter related to user importation – did I miss something? I’m not sure where else we’d hook that code to, as I can’t tell if there’s another way to distinguish regular users from imported users, other than as it’s happening…

Thanks.

Posted: Friday Dec 7th, 2012 at 8:41 am #33882

Does that principle apply to bulk deletes via the WordPress system too? I’ve noticed quite a discrepancy between the WP list and MC list as we’ve been testing this…

Please configure the settings here: [hilite path]Dashboard -› s2Member® -› API / List Servers -› Automate Unsubscribes/Opt-Outs[/hilite]

I’m not sure where else we’d hook that code to, as I can’t tell if there’s another way to distinguish regular users from imported users, other than as it’s happening…

You can process the list servers even if the user is already in MailChimp, nothing will change if he’s in the right list, but those that aren’t will be updated.

If you want to modify the importation tool, you may need to edit the file directly, there aren’t many hooks there. s2member-pro/includes/classes/imports-in.inc.php

You could make a copy of the file and move it to the /wp-content/mu-plugins/ directory and edit that, so it’s not overwritten when you update s2Member.

Posted: Monday Dec 10th, 2012 at 9:59 am #34139

On a related but separate issue, I’m having problems with SublimeText and imports-in.inc.php – specifically it’s causing SublimeLinter to freeze! Would you be happy for me to post the contents of just that php file to the SublimeLinter support group so I can ask why? It’s making editing it a pain, as I have to remember to turn off linting before starting!

Thanks!

Posted: Monday Dec 10th, 2012 at 2:36 pm #34167
Bruce
Username: Bruce
Staff Member

Hi Andy,

That’s interesting. Nonetheless you can see the source code here:

http://www.s2member.com/codex/stable/source/s2member-pro/includes/classes/imports-in.inc.php/

Posted: Monday Dec 10th, 2012 at 3:09 pm #34174

Thanks – it is weird, as I can run it through ‘php.exe -l’ with no problems, which is all SublimeLinter does… Ho hum – someone else’s problem now :)

Back to the issue at hand – I’ve added the following code to imports-in.inc.php in 2 places (at lines 216 and 332 of the original file), just before the ‘imported’ variable is incremented in each case. I think this is all that’s needed – any chance you could comment on whether I missed something? There seems to be a fair bit of redundancy in the parameters passed to process_list_servers (e.g. ‘level’ and ‘role’ – aren’t they pretty much the same thing?). Also, we obviously don’t have an IP address for imported users, so I’ve just left that blank.

Many thanks!

if(!c_ws_plugin__s2member_list_servers::process_list_servers(
	$role,
	(($role == "subscriber") ? 0 : substr($role, 14)), // Convert from descriptive back to numeric
	$user_login,
	'xxx',
	$user_email,
	$first_name,
	$last_name,
	'',
	true,
	false,
	$user_id
)) {
	$errors[] = 'List Server Update failed for user ' . $user_id;
}
Posted: Tuesday Dec 11th, 2012 at 7:33 am #34231

Regarding user deletions and the setting you mentioned (Dashboard -› s2Member® -› API / List Servers -› Automate Unsubscribes/Opt-Outs), I have ticked the top-level box labelled ‘Anytime a User is deleted ( including manual deletions )’.

I just deleted 16 users, but only the very first was unsubscribed from the MailChimp list, and the API logs from MC show only a single call was made. Could you confirm if this is a bug, and if it is, if there’s any more information I can dig out of logs, etc. which might show what went wrong?

Thanks!

Update: I just deleted a few more test users, this time in 2 goes, and saw 2 calls to the MC API, removing 1 user each time. So I suspect something which should be in a loop isn’t :)

Posted: Tuesday Dec 11th, 2012 at 2:28 pm #34285
Bruce
Username: Bruce
Staff Member

Hi Andy,

Update: I just deleted a few more test users, this time in 2 goes, and saw 2 calls to the MC API, removing 1 user each time. So I suspect something which should be in a loop isn’t :)

I’ll send this issue as a bug report to our dev team.

There seems to be a fair bit of redundancy in the parameters passed to process_list_servers (e.g. ‘level’ and ‘role’ – aren’t they pretty much the same thing?)

In s2Member’s processes, “level” usually refers to the s2Member level # (i.e. 1, 2, 3, 4), while role is the full role of the user (i.e. ‘admin’, ‘s2member_level0’, ‘editor’).

I don’t see anything jumping out at me in the code that’s wrong. Have you tested?

Posted: Thursday Dec 13th, 2012 at 5:06 am #34458

Well, it’s tested in the sense that I imported some users and they ended up subscribed to a MC list! So, not really tested, but at least on the face of it, it’s working. I’m sure there are extreme cases where things might not work as expected, but for now it’s OK. I was just covering bases to see if you could spot anything obvious I’d missed.

The redundancy I was referring to was just that most of the parameters can be derived from the user_id that is passed in, so I wasn’t sure why the function expected all the other parameters to be passed in separately, rather than just look them up – which is all I’ve done. Again, just wondering if I’d misunderstood something.

Thanks.

Viewing 10 replies - 1 through 10 (of 10 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.