Skip to content

Instantly share code, notes, and snippets.

@alex-georgiou
Created October 18, 2018 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex-georgiou/f063dd0565e562eb47c037cdf2d17547 to your computer and use it in GitHub Desktop.
Save alex-georgiou/f063dd0565e562eb47c037cdf2d17547 to your computer and use it in GitHub Desktop.
Example of how to restrict certain users from withdrawing certain coins in Bitcoin and Altcoin Wallets for WordPress
<?php
/*
* Plugin Name: Bitcoin and Altcoin Wallets: Fine-grained withdrawals blocking
* Description: Example of how to restrict certain users from withdrawing certain coins.
* Version: 1.0.0
* Plugin URI: https://gist.github.com/alex-georgiou/f063dd0565e562eb47c037cdf2d17547
* Author: Alexandros Georgiou <info@dashed-slug.net>
* Author URI: http://dashed-slug.net
* License: GPLv2 or later
*
*/
/**
* Restrict user1 from withdrawing BTC and user2 from withdrawing LTC.
*/
function block_withdrawals( $args ) {
$block = array(
array(
'user_login' => 'user1',
'symbol' => 'BTC',
),
array(
'user_login' => 'user2',
'symbol' => 'LTC',
),
);
if ( ! $args['from_user_id'] ) {
$args['from_user_id'] = get_current_user_id();
}
$user = get_user_by( 'ID', $args['from_user_id'] );
foreach ( $block as $b ) {
if ( $b['user_login'] == $user['user_login'] && $b['symbol'] == $args['symbol'] ) {
throw new Exception(
sprintf(
'User %s is not allowed to withdraw %s!',
$user['user_login'],
$b['symbol']
)
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment