Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
Created June 20, 2023 17:37
Show Gist options
  • Save damiencarbery/7dead3a6f4e92c89ae2d10a3b21b4e66 to your computer and use it in GitHub Desktop.
Save damiencarbery/7dead3a6f4e92c89ae2d10a3b21b4e66 to your computer and use it in GitHub Desktop.
Amelia: Allow on-site payments for admins - Allow site admin or Amelia Employees/Managers create appointments without making a payment.
<?php
/*
Plugin Name: Amelia: Allow on-site payments for admins
Plugin URI: https://www.damiencarbery.com/2023/06/amelia-allow-on-site-payments-for-admins/
Description: Allow site admin or Amelia Employees/Managers create appointments without making a payment.
Author: Damien Carbery
Version: 0.1
*/
// Disable on-site payments unless admin or Amelia Employee/Manager logged in. This forces customers to pay via Stripe.
add_filter( 'option_amelia_settings', 'dcwd_disable_onsite_for_bookings', 10, 2 );
function dcwd_disable_onsite_for_bookings( $amelia_settings, $option_name ) {
if ( is_admin() ) { return $amelia_settings; }
// If user is admin or Amelia Employee then do not change settings.
if ( current_user_can( 'manage_options' ) || current_user_can( 'amelia_delete_events' ) ) {
return $amelia_settings;
}
// Disable on-site payments as user is not admin or Amelia Employee. This forces customers to pay via Stripe.
$amelia_settings = str_replace( '"onSite":true', '"onSite":false', $amelia_settings );
return $amelia_settings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment