HEX
Server: LiteSpeed
System: Linux pulsar191.sitesanctuary.org 5.14.0-284.30.1.el9.tuxcare.els9.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jan 10 17:34:05 UTC 2025 x86_64
User: lgooir (1604)
PHP: 8.1.32
Disabled: exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/lgooir/www/wp-content/plugins/mailchimp-for-wp/integrations/memberpress/class-memberpress.php
<?php

defined('ABSPATH') or exit;

/**
 * Class MC4WP_MemberPress_Integration
 *
 * @ignore
 */
class MC4WP_MemberPress_Integration extends MC4WP_Integration
{
    /**
     * @var string
     */
    public $name = 'MemberPress';

    /**
     * @var string
     */
    public $description = 'Subscribes people from MemberPress register forms.';


    /**
     * Add hooks
     */
    public function add_hooks()
    {
        if (! $this->options['implicit']) {
            if (has_action('mepr_checkout_before_submit')) {
                add_action('mepr_checkout_before_submit', array( $this, 'output_checkbox' ));
            } else {
                add_action('mepr-checkout-before-submit', array( $this, 'output_checkbox' ));
            }
        }
        if (has_action('mepr_signup')) {
            add_action('mepr_signup', array( $this, 'subscribe_from_memberpress' ), 5);
        } else {
            add_action('mepr-signup', array( $this, 'subscribe_from_memberpress' ), 5);
        }
    }



    /**
     * Subscribe from MemberPress sign-up forms.
     *
     * @param MeprTransaction $txn
     * @return bool
     */
    public function subscribe_from_memberpress($txn)
    {

        // Is this integration triggered? (checkbox checked or implicit)
        if (! $this->triggered()) {
            return false;
        }

        $user = get_userdata($txn->user_id);

        $data = array(
            'EMAIL' => $user->user_email,
            'FNAME' => $user->first_name,
            'LNAME' => $user->last_name,
        );

        // subscribe using email and name
        return $this->subscribe($data, $txn->id);
    }

    /**
     * @return bool
     */
    public function is_installed()
    {
        return defined('MEPR_VERSION');
    }
}