Created
October 18, 2018 08:55
-
-
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
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 | |
/* | |
* 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