Created
September 2, 2018 13:06
-
-
Save wpmudev-sls/2206cfcd41a4e8cf6be1a9cffcae8cb2 to your computer and use it in GitHub Desktop.
MS bypass trial depend on user accept custom field
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 | |
/** | |
* Plugin Name: MS bypass trial depend on user accept custom field | |
* Description: MS bypass trial depend on user accept custom field | |
* Author: Ariful Islam @ WPMUDEV | |
* Author URI: https://premium.wpmudev.org/profile/itsarifulislam | |
* License: GPLv2 or later | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
add_filter( 'ms_model_relationship_is_trial_eligible', function( $status, $relation ) { | |
$member = $relation->get_member(); | |
if ( ! $member ) return $status; | |
return !! $member->get_custom_data('accept_trial'); | |
}, 10, 2); | |
add_action( 'register_form', function() { | |
?> | |
<div class="ms-form-element ms-form-element-privacy_check"> | |
<label class="wpmui-checkbox-wrapper wpmui-field-label "> | |
<input id="accept_trial" class="wpmui-field-input wpmui-field-checkbox" type="checkbox" checked name="accept_trial" value="1"> | |
<div class="wpmui-checkbox-caption"><?php echo __('Accept Trial?', 'membership'); ?></div> | |
</label> | |
</div> | |
<?php | |
}); | |
add_action( 'ms_controller_frontend_register_user_before_login', function( $user, $req ) { | |
$accept_trial = ( isset($req['accept_trial']) && $req['accept_trial'] ) ? 1 : 0; | |
$user->set_custom_data('accept_trial', $accept_trial); | |
$user->save(); | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
guide me