• Resolved Steve Bruner

    (@sbruner)


    Great job on this plugin. Really flexible and amazing.

    I’d like to add some text and an link after the poll results are shown. I’m hooking into wp_polls_vote_poll_success and pulling data from a custom field, but it’s not showing.

    I also tested showing $post, but that’s not working either. Only static text seems to work.

    Do you have a recommended way to show dynamic text after the poll results are shown?

    Thank you so much!

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Lester Chan

    (@gamerz)

    Unfortunately you can’t do that, the hook wp_polls_vote_poll_success is used normally to log something into a custom database upon a successful vote. Since the poll is based around on templates, you can’t dynamically inject anything

    Thread Starter Steve Bruner

    (@sbruner)

    Hi Lester– thanks for getting back to me.

    Is it possible to create custom template tags? Would that work to pull in dynamic text?

    Plugin Author Lester Chan

    (@gamerz)

    That is possible, you can modify the plugin as you wish. But as with every plugin update, the changes will be wiped.

    Thread Starter Steve Bruner

    (@sbruner)

    Hi Lester– Is there a way to register custom templates? I’m not interested in modifying you plugin, only extending it.

    Thanks
    Steve

    Plugin Author Lester Chan

    (@gamerz)

    Unfortunately nope, the plugin was not designed for that!

    Thread Starter Steve Bruner

    (@sbruner)

    I’d be happy to sponsor the addition of this feature. Is this something you would be open to doing?

    Plugin Author Lester Chan

    (@gamerz)

    I don’t think I will have time to do it. You can always hire a dev to fork the plugin and extend it and send back a Pull Request.

    Thread Starter Steve Bruner

    (@sbruner)

    That’s fine. Can you provide some insight on how you recommend we do it?

    Plugin Author Lester Chan

    (@gamerz)

    I think the easier way I would do it is to abstract out a function to get all templates and then the output of this function will return a filter of the templates so that your theme/plugin can overwrite the template.

    Thread Starter Steve Bruner

    (@sbruner)

    I submitted a pull request. Simply filtered the results markup:
    https://github.com/lesterchan/wp-polls/pull/86/commits/4cb886826f80f9b6ee5f134e6a2c9265c6219d86

    Let me know what you think.

    Steve

    Plugin Author Lester Chan

    (@gamerz)

    Sounds good!, merged!

    Thread Starter Steve Bruner

    (@sbruner)

    Great! Thank you so much.

    Would you be willing to explain how to add the custom text when the poll results show? I’d like to offer a thank you note to those who take the survey. It sounds like you guys resolved hooking into wp_polls but I’m not experienced enough to know how to code the filter hook and where to put it to avoid being overwritten. If you’d be willing to share a snippet of what the example code would like and where to paste it I would appreciate it very much.

    Thread Starter Steve Bruner

    (@sbruner)

    Add this to your custom plugin or functions.php:

    function my_after_poll_results($results) {
        $results .= 'Thank you';
    
        return $results;
    }
    add_filter( 'poll_result_markup', 'my_after_poll_results');
    • This reply was modified 7 years, 8 months ago by Steve Bruner.

    Thank you so much for your help, this is exactly what I was looking for.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Using wp_polls_vote_poll_success hook’ is closed to new replies.