Last active
January 9, 2020 12:23
-
-
Save Pebblo/f952f806aec55df5f8a1 to your computer and use it in GitHub Desktop.
This is an example of how you can add payment methods to the available payment methods on the front end for admin users only. This function will add the 'Invoice' payment method that admins can select on the front end of the site, (any user without the 'manage_options' cap will not see the PM). This is useful for allowing users to use Multi Even…
This file contains hidden or 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: Event Espresso site specific functions | |
| Description: Add custom functions for Event Espresso to this plugin. | |
| /* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */ | |
| function tw_ee_output_admin_invoice_payment_method($payment_methods, $transaction, $scope) { | |
| //Check if the user is logged in, is not within the admin and has the correct capability | |
| if( is_user_logged_in() && current_user_can( 'manage_options' ) ) { | |
| //Check we are within SPCO | |
| $checkout = EE_Registry::instance()->SSN->checkout(); | |
| if ( $checkout instanceof EE_Checkout ) { | |
| //Sanity check to check we have a valid EE_Transaction object | |
| if ( $transaction instanceof EE_Transaction) { | |
| //Pull in an Invoice payment method. | |
| $invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type( 'Invoice' ); | |
| //Check we actually have an EE_Payment_Method object and add it to the payment methods. | |
| if( $invoice_payment_method instanceof EE_Payment_Method ) { | |
| $payment_methods[] = $invoice_payment_method; | |
| } | |
| } | |
| } | |
| } | |
| return $payment_methods; | |
| } | |
| add_filter('FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods', 'tw_ee_output_admin_invoice_payment_method', 10, 3 ); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
References:
https://eventespresso.com/topic/cant-inherit-abstract-function-eei_eventname/