• Resolved shurix239

    (@shurix239)


    Hello,

    first of all, thank you for a great plugin you created.

    My question is there a way to implement sharing to Instagram, Whatsapp and other social nets, not only facebook and twitter? Since I’m a developper, may be you could suggest which files should be touched to implement this.

    Thank you

Viewing 1 replies (of 1 total)
  • Plugin Author Harmonic Design

    (@harmonic_design)

    Hi shurix239,
    Just curious, but how do you plan on sharing a quiz on instagram? Do you plan on auto generating a jpg of the results and sharing as a post? If so, how do you plan to ensure that generated image is the correct aspect ratio? DO you man n just sharing as a DM? Or perhaps a story (same issue as with the post).

    Instead of modify the plugin itself (which is almost never recommended) I recommend using the actions I built into HD Quiz. Specifically, the hdq_submit and hdq_before or hdq_after actions.

    Add the following PHP to your theme’s functions.php file. This will tell HD Quiz to look for and run a JS script when the quiz is submitted. We want to run our code once the quiz has been submitted so that we can use the quiz score as part of whatever you want to share.

    How To Use:

    // Tell HD Quiz to look for and execute the following JS function  - shurix239
    function hdq_shurix239_submit($quizOptions)
    {
        array_push($quizOptions->hdq_submit, "hdq_shurix239");
        return $quizOptions;
    }
    add_action('hdq_submit', 'hdq_shurix239_submit');

    Now we need to add the javascript. Now, you can add this code directly to your theme’s footer or something if you want, but by using the hdq_before action, we can ensure that this code will ONLY load on pages that have a quiz on it.

    function hdq_shurix239_js($quizOptions)
    { ?>
    <script>
    function hdq_shurix239() {
      // this function fires off once a quiz has been submitted
      const hdq_social_icon = document.getElementsByClassName(“hdq_social_icon”)[0]; // get the fist quiz social share
      const data = “put whatever html you need here – link + icon + onClick event + whatever”;
      hdq_social_icon.insertAdjacentHTML(“beforebegin”, data);
    }
    </script>
    <?php }
    add_action(‘hdq_before’, ‘hdq_shurix239_js’);
Viewing 1 replies (of 1 total)
  • The topic ‘Instagram, whatsap etc sharing’ is closed to new replies.