Created
February 4, 2017 06:52
-
-
Save supercleanse/35e0257255d9c784ca52e038b152a82d to your computer and use it in GitHub Desktop.
List Sub Account Management Links
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 | |
$current_user = wp_get_current_user(); | |
// Returns results from $wpdb->get_results ... not an array of MPCA_Corporate_Account objects | |
$corporate_accounts = MPCA_Corporate_Account::get_all_by_user_id($current_user->ID); | |
foreach($corporate_accounts as $ca_row) { | |
// Create blank MPCA_Corporate_Account object | |
$ca_obj = new MPCA_Corporate_Account(); | |
// Load row data into a MPCA_Corporate_Account object | |
$ca_obj->load_from_array($ca_row); | |
// Get the subscription / transaction object for the corporate account | |
$sub_obj = $ca_obj->get_obj(); | |
// Create link title based on the subscription subscr_id if recurring | |
// or if non-recurring, the transaction trans_num | |
$sub_title = sprintf( | |
__('Manage Sub Accounts for Subscription: %s'), | |
($sub_obj instanceof MeprSubscription ? $sub_obj->subscr_id : $sub_obj->trans_num) | |
); | |
?> | |
<div><a href="<?php echo $ca_obj->sub_account_management_url(); ?>"><?php echo $sub_title; ?></a></div> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment