Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Creates a log at /paid-memberships-pro/logs/level-change.txt for whenever a membership level is changed.
<?php
// Copy from below here...
/*
* Creates a log at /paid-memberships-pro/logs/level-change.txt for whenever a membership
* level is changed.
*/
function my_pmpro_after_change_membership_level_log( $level_id, $user_id, $cancel_level ) {
$logstr = "Logged On: " . date_i18n("m/d/Y H:i:s") . "\n";
$logstr .= "Level: " . $level_id . "\n";
$logstr .= "User ID: " . $user_id . "\n";
$logstr .= "Cancel Level: " . $cancel_level . "\n";
$logstr .= "Request URI: " . $_SERVER['REQUEST_URI'] . "\n";
$logstr .= "\n-------------\n";
$loghandle = fopen(PMPRO_DIR . "/logs/level-change.txt", "a+");
fwrite($loghandle, $logstr);
fclose($loghandle);
}
add_action( 'pmpro_after_change_membership_level', 'my_pmpro_after_change_membership_level_log', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment