Run button click on WP Admin with Add_action

I created a simple button in my ADMIN wordpress.

<button type = "button"> RUN </ button>
I would like a function that is in function.php only executed when I click RUN.

I can add my function:

add_action ('my_action', 'my_function');
But how do I call the function when I click the button?

Hey @Gih, I moved the topic to the CMS & WordPress category, hope that’s OK. :-) Now what exactly is that button supposed to do? It seems you are confusing two different things here… clicking a button is a browser event, so the PHP scripts have already run and served a given page (the admin panel in that case). The add_action() function however hooks a function to an action during the server side script execution. Now what you can do is setting a value in the database when you click the button (although you’ll usually submit a whole form with some given options), and check for that value somewhere in your functions.php.

Thanks M3g4p0p

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.