dashed-slug.net › Forums › General discussion › No trigger from action hooks
Tagged: action, callback, notification, notify, transaction wallets_transaction, wallets_deposit, wallets_move_receive
- This topic has 3 replies, 2 voices, and was last updated 5 years, 11 months ago by alexg.
-
AuthorPosts
-
January 6, 2019 at 12:42 pm #5489AnonymousInactive
I created a simple plugin to receive information from action hooks
wallets_move_receive
andwallets_transaction
as per your instructions, so I could check transaction information for testing and debugging purposes. But, for some reason, after one or all of the following four operations, my pluggin stopped saving tx info as before:1. Updated wallet to 3.93
2. Installed new theme
3. Installed BuddyPress
4. Installed WoocommerceNothing in the error logs, no php errors.
What I tried, but no luck:
- Deactivating and reactivating wallet core plugin;
- Deactivating and reactivating my plugin;
- Changed name of my plugin to z-something (trying to load last);
- Gave priority 1 to my custom action to wallet hook
wallets_move_receive
Aside from the fact that BudyPress is not receiving any notifications for transactions, everything else regarding the wallet seems to work fine. My perception is that my plugin is loading before the wallet plugin, that would be the reason for not triggering the actions. Any ideas on what’s going on? Thanks for your help.
January 6, 2019 at 12:54 pm #5491AnonymousInactiveCustom plugin code (headers removed):
function my_action_wallets_move_receive( $data ) {error_log( print_r( $data, true ) ); // prints out a stdClass object
$file="/var/www/html/txs/logs/wallets_move_receive-tx-". date('Y-m-d') .".logfile";
if (!file_exists($file))
{
// create file
file_put_contents($file, " ", FILE_APPEND);
chmod($file,0660);
}file_put_contents( $file,print_r( $data, true ),FILE_APPEND );
}//add_action( 'wallets_move_receive', 'my_action_wallets_move_receive' ,1,1);
add_action( 'wallets_move_receive', 'my_action_wallets_move_receive');
January 6, 2019 at 7:30 pm #5495AnonymousInactiveSolved, my bad: I was directing the cron script to another development node with same application. In order to trigger transactions as I was planning, I *must* use only one node for completing transactions via
curl /?__wallets_action=do_cron&__wallets_apiversion=3&__wallets_cron_nonce=XXXX
I hope this thread can help somebody else with same issue.January 7, 2019 at 10:11 am #5496alexgKeymasterHello,
I’m glad you resolved the issue. Some comments:
You only need to trigger cron yourself if the WordPress cron job does not execute automatically via WordPress, or alternatively you can do this to improve performance, but it is not strictly necessary otherwise.
You should not rely on the plugins to load in any particular ordering. In fact, this is why we use hooks in the first place, to avoid race conditions on the interfaces between different plugins/themes and WordPress itself. I see from your commented out code that you already know about priorities. As long as you bind your hooks correctly they should execute in the correct precedence.
If you are running two WordPress instances connecting to the same wallet instance, you need to be careful to maintain enough hot wallet balance for both instances. Personally I don’t think it’s a good idea in terms of security. But if you want to do this, you would need to modify the
walletnotify
command to do acurl
on both your WordPress instances. This will allow both sites to be notified of any new deposit transactions. The plugin will know to record each transaction on the correct site only.with regards
-
AuthorPosts
- You must be logged in to reply to this topic.