221 posts
  • Has been part of the Envato Community for over 4 years
  • Located in United Kingdom
  • Has sold $1,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+2 more
NuclearThemes
says

I’m having a bit of a mental block at the moment. I have two buttons in a WP plugin that need to run separate functions. I can only think of one way to do it but it doesn’t sound like the best solution.

Encase each button in a form with a hidden field. Is there a better way?

3532 posts
  • Became a Top 20 Author of the Month
  • Had an item that was trending
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
+12 more
sevenspark
Moderator
says

Or you can place two submit buttons in the same form, give them different names, and test for which name was submitted on the back end. Only the input button that was clicked will be submitted in the form data. :)

221 posts
  • Has been part of the Envato Community for over 4 years
  • Located in United Kingdom
  • Has sold $1,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+2 more
NuclearThemes
says

Precisely what was needed, thanks :)

3532 posts
  • Became a Top 20 Author of the Month
  • Had an item that was trending
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
+12 more
sevenspark
Moderator
says

You’re welcome :)

by
by
by
by
by
by