I have a problem with Wordpress shortcode and Elementor. Let's say that I have the following shortcode inside functions.php:
function some_shortcode($atts) {
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
echo 'It works!';
}
}
add_shortcode('shortcode', 'some_shortcode');
Next, i put the following HTML code to page using Elementor:
[shortcode]
<form method="POST">
<button type="submit">Click me</button>
</form>
I'd really love to the shortcode function executes only when the user clicks the form button (so when the POST method happens) but in fact, the shortcode is executed all the time (looks like if the condition inside the shortcode function doesn't work). Could you tell me, please, how can I make the shortcode working only after the form button click?