I constructed a pleasant system that simulates a “battle” when a sure button is pressed, it updates the customers’ information accordingly, in the mean time it really works on one step and it’s inbuilt a plugin, I wished to understand how I make an individual press a button and replace his particulars and the identify of his “opponent” accordingly
For instance I’m on the web page: /profile/twar/single-attack-profile/
I must retrieve the identify or the ID of that participant (twar)
and replace my consumer and the twar participant the information accordingly, if I win then I get for instance 100 gold however he loses 100 gold and it must be up to date accordingly, does anybody have an concept or a strategy to apply this calculation?
Notice: The system was constructed with plugins and a plugin that saves the meta secret is crocoblock
I considered one thing like this to replace my present consumer:
<?php
$user_id = get_current_user_id();
$key = 'gold';
$single = true;
$user_last = get_user_meta( $user_id, $key, $single );
echo $user_last;
update_user_meta( $user_id, $key, 1000+$user_last );
?>