Created
December 21, 2023 18:22
-
-
Save tobeyadr/c98e2128796438883fdf3e9d0325c1d6 to your computer and use it in GitHub Desktop.
When a member becomes active in MemberPress change their opt-in status to confirmed and set their consents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'mepr-account-is-active', 'set_contact_optin_status_and_consent', 11 ); | |
/** | |
* When a member becomes active in MemberPress change their opt-in status to confirmed and set their consents | |
* | |
* @param $txn | |
* | |
* @return void | |
*/ | |
function set_optin_status_and_consent( $txn ) { | |
$contact = \GroundhoggMemberPress\Plugin::instance()->event_handler->get_contact_from_txn( $txn ); | |
// Change to confirmed | |
$contact->change_marketing_preference( \Groundhogg\Preferences::CONFIRMED ); | |
// Update their consents | |
$contact->set_marketing_consent(); | |
$contact->set_gdpr_consent(); | |
$contact->set_terms_agreement(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment