Support » Plugin: WP-MQTT » WP-WQTT: How to define custom placeholders?

  • Resolved janfiess


    Thanks for sharing your great work on MQTT.
    You wrote that I could create my own placeholder. But I am not able to figure out how. I have no example nor guide.
    Can you please describe how to define custom placeholders, that publish MQTT messages to the broker when e.g. a button is pressed?
    That would be really helpful.
    Thanks in advance.
    Best wishes Jan

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


    Hello Jan. A placeholder in WP-MQTT is a short string that you can place inside your MQTT message field, that gets replaced by actual content. When using events like “post published”, you can use %POST_ID% in your message, to receive the new post’s ID number.

    The idea behind WP-MQTT is to publish MQTT messages when WordPress events happen. If the button you’re referring to triggers a WordPress hook, or a hook in a plugin or theme, than you can use WP-MQTT to (also) send out an MQTT message. There’s a lot of info in the “help” section on the plugin’s admin screen.

    If your button is just a button in a post or page, that does not trigger any WordPress hooks when pressed, than I’m afraid WP-MQTT is currently not able to send out a message when it’s pressed.

    But if you – as an example – would set up a Gravity Forms form, you could get it to work because submitting GF forms triggers hook defined in the Gravity Forms plugin. Lots of things trigger hooks in WP.

    Thanks for your detailed reply!
    However, I have not found the help section yet. Where should it be?
    On the page where all plugins are listed, among them WP-MQTT? There is a Help button in the top right corner, but I find nothing about WP-MQTT?
    This really sounds like a very beginner question oh oh 🙂
    I’m sorry.

    Plugin Author Roy Tanck


    No worries. If you go to the settings page for my plugin (Settings -> WP-MQTT), there should again be that little tab in the top right corner of the screen, labeled ‘help’. That help section is contextual, so on this page it’s about WP-MQTT.

    Yes, now I found the Help button. It was actually hidden for me (I had to scroll to the right in the browser window).
    Basically your plugin makes a good job. For the operations you mentioned, WP-MQTT works at a glance.
    However, considering Gravity Forms for making a button publishing MQTT events, submitting a form and refreshing the web page each time you hit the Submit button, is not the way to go for me.
    It would be awesome if one day there is something more integrated in the text to publish MQTT events, like [WP-MQTT Topic”myTopic”Payload”myPayload”].
    Moreover, a possibility to subscribe to events would be fine, too.
    In the meantime, I will create an extra Node.js application, doing the MQTT stuff. I hope, I future this won’t be necessary any more.
    Thanks and
    Keep on developing. I’m sure it would be worth the effort.

    Plugin Author Roy Tanck


    It seems that your use case does not really match what WP-MQTT was designed to do.

    If you’d like to stick with WP, you could also create a little plugin that adds a shortcode like the one you mentioned. On click, the button (inserted by the shortcode) could then send out an AJAX request to WP, which would trigger a hook that WP-MQTT can use.

    I thought about WP as an MQTT client too, but since WordPress only runs while pages are being generated, it would be challenging to create a way to have it listen for new messages continuously.

    I see. Thanks for the hint.
    Maybe you are right with AJAX, but this is indeed more challenging for me than using node, because I am more familiar with node.
    Guess, I need to do some tests 🙂

    Plugin Author Roy Tanck


    Best of luck with your project!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘WP-WQTT: How to define custom placeholders?’ is closed to new replies.