• I’m trying to do a button controlled MQTT message sender in my WordPress site with the help of WP-MQTT. But I’m newbie in this area of HTML, PHP and other things, and I don’t understand very well the hook structure that the plugin need to do a custom event. Anyone can help me?

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Roy Tanck

    (@roytanck)

    WP_MQTT uses WordPress’s internal event (called ‘hooks’) to trigger messages. Its main purpose is to send messages when something happens on your site, such as a new page being posted or a comment being marked as spam. A user clicking a button in a page does not fire a hook.

    in your case, the trick is to create a button that does fire a hook. If your button would post to the REST API for instance, the function that handles that request could fire a custom hook, that WP-MQTT could then use to trigger a message.

    This will certainly require a bit of PHP programming. There’s plenty of documentation about the REST API, and WordPress’s hooks system is absolutely worth diving into.

Viewing 1 replies (of 1 total)
  • The topic ‘How to send a MQTT message when an user clicks in a button?’ is closed to new replies.