Skip to content

Commit 48b3afe

Browse files
Merge branch 'feature/issue-696-peepso-integration' of github.com:faisalahammad/mailchimp-for-wordpress into faisalahammad-feature/issue-696-peepso-integration
2 parents 0c876d2 + d68c8c3 commit 48b3afe

3 files changed

Lines changed: 67 additions & 0 deletions

File tree

autoload.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
'MC4WP_Ninja_Forms_Field' => '/integrations/ninja-forms/class-field.php',
6363
'MC4WP_Ninja_Forms_Integration' => '/integrations/ninja-forms/class-ninja-forms.php',
6464
'MC4WP_Ninja_Forms_V2_Integration' => '/integrations/ninja-forms-2/class-ninja-forms.php',
65+
'MC4WP_PeepSo_Integration' => '/integrations/peepso/class-peepso.php',
6566
'MC4WP_Plugin' => '/includes/class-plugin.php',
6667
'MC4WP_Procaptcha_Integration' => '/integrations/prosopo-procaptcha/class-procaptcha-integration.php',
6768
'MC4WP_Procaptcha' => '/integrations/prosopo-procaptcha/class-procaptcha.php',

integrations/bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function mc4wp_admin_after_integration_settings(MC4WP_Integration $integration,
4141
mc4wp_register_integration('contact-form-7', 'MC4WP_Contact_Form_7_Integration', true);
4242
mc4wp_register_integration('events-manager', 'MC4WP_Events_Manager_Integration');
4343
mc4wp_register_integration('memberpress', 'MC4WP_MemberPress_Integration');
44+
mc4wp_register_integration('peepso', 'MC4WP_PeepSo_Integration');
4445
mc4wp_register_integration('affiliatewp', 'MC4WP_AffiliateWP_Integration');
4546
mc4wp_register_integration('give', 'MC4WP_Give_Integration');
4647
mc4wp_register_integration('custom', 'MC4WP_Custom_Integration', true);
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
defined('ABSPATH') or exit;
4+
5+
/**
6+
* Class MC4WP_PeepSo_Integration
7+
*
8+
* @ignore
9+
*/
10+
class MC4WP_PeepSo_Integration extends MC4WP_User_Integration
11+
{
12+
/**
13+
* @var string
14+
*/
15+
public $name = 'PeepSo';
16+
17+
/**
18+
* @var string
19+
*/
20+
public $description = 'Subscribes users from PeepSo registration forms.';
21+
22+
/**
23+
* Add hooks
24+
*/
25+
public function add_hooks()
26+
{
27+
if (! $this->options['implicit']) {
28+
add_action('peepso_register_extended_fields', [ $this, 'output_checkbox' ], 20);
29+
}
30+
31+
add_action('peepso_register_new_user', [ $this, 'subscribe_from_peepso' ], 10, 1);
32+
}
33+
34+
/**
35+
* Subscribes from PeepSo Registration Form.
36+
*
37+
* @param int $user_id
38+
* @return bool
39+
*/
40+
public function subscribe_from_peepso($user_id)
41+
{
42+
if (! $this->triggered()) {
43+
return false;
44+
}
45+
46+
$user = get_userdata($user_id);
47+
48+
// was a user found with the given ID?
49+
if (! $user instanceof WP_User) {
50+
return false;
51+
}
52+
53+
$data = $this->user_merge_vars($user);
54+
55+
return $this->subscribe($data, $user_id);
56+
}
57+
58+
/**
59+
* @return bool
60+
*/
61+
public function is_installed()
62+
{
63+
return class_exists('PeepSo');
64+
}
65+
}

0 commit comments

Comments
 (0)