Forked from JudeRosario/(Future use) Delete user on cancel.php
Created
May 11, 2017 08:14
-
-
Save ionatan-israel/eb84e5794666402d6dfcb6759b899d6d to your computer and use it in GitHub Desktop.
Delete user on membership cancel
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
add_action('ms_gateway_cancel_membership', 'm2_delete_user', 999, 1) ; | |
function m2_delete_user( $sub ) { | |
wp_delete_user( $sub->user_id ); | |
} |
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
function corn_activation() { | |
if ( !wp_next_scheduled( 'daily_membership_check' ) ) { | |
wp_schedule_event( current_time( 'timestamp' ), 'daily', 'daily_membership_check'); | |
} | |
} | |
add_action('wp', 'corn_activation'); | |
add_action('daily_membership_check', 'do_this_daily'); | |
function do_this_daily() { | |
$blogusers = get_users( array( 'role' => 'subscriber' ) ); | |
// Array of WP_User objects. | |
foreach ( $blogusers as $user ) { | |
$member = MS_Factory::load( 'MS_Model_Member', $user->ID ); | |
if ( $member->has_membership() ) | |
wp_delete_user( $user->ID ) ; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment