can now cease a membership too

master
Marek Isalski 6 years ago
parent 29e742394b
commit 6eab2ea47b

@ -132,6 +132,22 @@ function fulcrm_membership_optin( $passport ) {
}
}
function fulcrm_membership_can_self_set_person2membership( $p2m ) {
if ( array_key_exists( 'membership', $p2m ) ) {
if ( is_array( $p2m[ 'membership' ] ) )
$membership_id = $p2m[ 'membership' ][ 'id' ];
else
$membership_id = fulcrm_apiv2_url_to_pk( $p2m[ 'membership' ] );
$self_set_membership_ids = variable_get( 'fulcrm_membership_self_set_membership_ids', array() );
if ( array_key_exists( $membership_id, $self_set_membership_ids ) ) {
if ( $self_set_membership_ids[ $membership_id ] )
return true;
}
}
return false;
}
function fulcrm_membership_cease_person2membership( $p2m, $now = NULL ) {
if ( is_null( $now ) )
$now = new DateTime();
@ -140,7 +156,7 @@ function fulcrm_membership_cease_person2membership( $p2m, $now = NULL ) {
$finish = $now->format( 'Y-m-d\TH:i:s.u\Z' );
if ( $p2m[ 'timescale' ] ) {
$api_data = fulcrm_apiv2_PATCH( $p2m[ 'url' ], $data = array( 'finish' => $finish ) );
$api_data = fulcrm_apiv2_PATCH( $p2m[ 'timescale' ][ 'url' ], $data = array( 'finish' => $finish ) );
if ( $api_data[ 'success' ] ) {
return true;
} else {

Loading…
Cancel
Save