Skip to content

Instantly share code, notes, and snippets.

@robertuniqid
Created October 26, 2018 18:55
Show Gist options
  • Save robertuniqid/59d0c466bd5081833d0d16bc45391b51 to your computer and use it in GitHub Desktop.
Save robertuniqid/59d0c466bd5081833d0d16bc45391b51 to your computer and use it in GitHub Desktop.
Sales Engine Access Rules PHP Example
<?php
// You'll want to get an User Access Rules Instance list this :
$user_access_rule = new WPEPAddOnSalesEngine\Entity\UserAccess( $user_id );
// Case 1 : Give Access to One-Time Purchases ( not Memberships )
// $post_id = Post Type, if it's a Membership, you can set an Expiration date also.
$user_access_rule->get_post_access_rules( $post_id )->give_access(); // when giving access it will save automatically.
// Case 2 : Change the Expiration Date on a Membership
$membership_access_rules = $user_access_rule->get_post_access_rules( $membership_id );
$membership_access_rules->set_expiration_time( $expiration_time ); // Expiration Time as Date or
$membership_access_rules->save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment