Skip to content

Instantly share code, notes, and snippets.

@wpmudev-sls
Created September 2, 2018 13:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpmudev-sls/2206cfcd41a4e8cf6be1a9cffcae8cb2 to your computer and use it in GitHub Desktop.
Save wpmudev-sls/2206cfcd41a4e8cf6be1a9cffcae8cb2 to your computer and use it in GitHub Desktop.
MS bypass trial depend on user accept custom field
<?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 );
@allan000001
Copy link

guide me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment