Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.