I have created a HTML form inside a PHP file in Wordpress similar as below:
<form>
<input id="currentProjectId" type="hidden" />
<input id="expertiseCheck" class="custom-control-input" type="checkbox"/>
<label class="custom-control-label" for="expertiseCheck">Contribute with expertise</label>
<button class="btn btn-primary">Submit</button>
</form>
Now, I want to execute a PHP function when the form is submitted that is able to access the values inserted in the form (such as in the input expertiseCheck or currentProjectId) and do some action after the form has been submitted (belonging to other plugins).
I have tested how to call a function from functions.php using wp-admin or wp-ajax actions. However, I would like to know a method that does not redirect to wp-admin.php or other pages but that instead processes the submission in the background and stays on the same page, as a javascript function would do (but I can not use one because I need to call PHP functions)
Thank you in advance!