how can I automatically fetch email addresses of my course students for mailchimp?

Hi,

I have several courses.

I would like that each time a new student enrolls, they are automatically subscribed to an autoresponder for that particular course, on mailchimp or ActiveCampaign. This way, I can get them on (a) a consumption & engagement sequence and (b) an upsell sequence.

I know this is not a function currently in CoursePress Pro. But what do you suggest is the best way to achieve the above goal? I can get a programmer to do it, I just need advice on the best approach. Most of all, I need an approach that will survive automatic plugin updates.

I am most grateful for any guidance on this matter.

Thanks!

David

  • Adam Czajczyk
    • Support Gorilla

    Hey David,

    I hope you're well today and thank you for your question!

    You're right about CoursePress not supporting MailChimp (or ActiveCampaign) integration right out of the box, however there's a feature request on our "Features and feedback" forum already so feel free to support it by giving it a vote.

    https://premium.wpmudev.org/forums/topic/can-i-integrate-coursepress-with-mailchimp

    That said, there are two workarounds also described in this aforementioned thread. You can use our MailChimp Newsletter Integration plugin:
    https://premium.wpmudev.org/project/mailchimp-newsletter-integration/

    It will automatically subscribe every new user to your list.

    Another way would be to use our Protected Content plugin and sell courses through member's subscriptions. This plugin has a MailChimp integration built-in.

    https://premium.wpmudev.org/project/protected-content/

    Finally, you can create your own custom solution. The best approach in my opinion would be to grab student's email from his/her profile (which is a "user_email" in "wp_users" db table) - the same way as CoursePress does.

    I hope that helps and if you have any further questions, please ask. I'll be glad to assist!

    Cheers,
    Adam

  • David
    • Site Builder, Child of Zeus

    Hi @Adam Czajczyk,

    Thank you for the tip. I think for me the best would be to grab student's email from his/her profile (which is a "user_email" in "wp_users" db table) , like you say.

    So how do I know which user_email to grab for each course? I have 8 courses, so I cannot just grab all the users and dump them into one list. I need to know that Course A has these bunch of students, Course B this bunch.... what tables should my programmer be looking at to fetch the records correctly?

    Thanks,

    David

  • Adam Czajczyk
    • Support Gorilla

    Hey David,

    I agree that this would probably be the best way. So basically, you need to

    - find users IDs of the students enrolled for particular course
    - pull e-mail addresses of those students from WP users table

    Every course is a post (a bunch of posts actually but that's not important here) of "course" type. By finding all those posts (from "wp_posts" table) you'll get courses' IDs.

    To find all students enrolled for the particular course, search the "wp_usermeta" table for "meta_key" of value "course_X", replacing "X" with the course ID. Then pull user's ID from the "user_id" field of the result.

    From now on you'll be able to get students emails simply by reading them from "wp_users" table.

    I hope that helps!

    Cheers,
    Adam

  • David
    • Site Builder, Child of Zeus

    Hi,

    I just started implementing this and realised, "how can I get the custom code to know that a new user has enrolled, so that it fetches the data?" Is there a webhook or something I can hack into so that my script can detect the moment a new student enrolls?

    Thanks,

    David

  • Adam Czajczyk
    • Support Gorilla

    Hey David!

    I just started implementing this and realised, "how can I get the custom code to know that a new user has enrolled, so that it fetches the data?"

    That's a great question of which I haven't thought :slight_smile:

    You may want to try something like this:

    function my_function($student_id,$course_id) {
     /... you should be able to use both studen's and course's IDs here .../
    }
    add_action('coursepress_student_enrolled', 'my_function');

    Let me know if it works for you, please!

    Cheers,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.