Join our Facebook Group
ScriptsTribe • Sngine • Community
Join

Форумы

The great place to discuss topics with other users

Sngine Do Not Sell/Share My Data Addon for you.

'
Join the Conversation Ответить
Edy Lee
Admin
Joined: 2024-11-24 00:57:42
2025-09-27 00:18:43

To allow users to opt out from getting their data sell 

UNITY LOVE
Member
Joined: 2025-02-06 18:06:38
2025-09-27 00:28:17

Installation

  1. Upload the contents of the zip into your Sngine root directory.

    • includes/ajax/do_not_sell.php

    • content/themes/yourtheme/templates/_do_not_sell.tpl

    • install.sql

  2. Run install.sql on your MySQL database to add the new column:

     
    ALTER TABLE users ADD COLUMN do_not_sell TINYINT(1) NOT NULL DEFAULT 0;
     
    • In your theme footer template (_footer.tpl), include the modal:

       
      {include file="_do_not_sell.tpl"}
    • Clear cache and refresh your site.

    1. Database Update

    Extend install.sql:

     
    ALTER TABLE users ADD COLUMN allow_ads TINYINT(1) NOT NULL DEFAULT 1;

    (Defaults to 1 so personalized ads are allowed until user opts out.)


    2. Update Modal Template (_do_not_sell.tpl)

    Replace your modal content with this:

     
    <!-- Do Not Sell or Share My Personal Data --> <a href="#" id="dns-trigger" class="small text-muted">Privacy & Data Preferences</a> <div id="dns-overlay" class="dns-overlay" role="dialog" aria-modal="true" aria-labelledby="dns-title"> <div class="dns-modal" role="document"> <button class="dns-close" id="dns-close">&times;</button> <h2 id="dns-title">Privacy & Data Preferences</h2> <!-- Do Not Sell --> <h5>Do Not Sell or Share My Personal Data</h5> <p> By choosing this option, you are requesting that {$system['system_title']} does not sell or share your personal information. </p> <div class="dns-actions mb-3"> <button class="btn btn-primary w-100" id="dns-confirm">Do Not Sell or Share My Data</button> </div> <hr> <!-- Personalized Ads --> <h5>Personalized Advertising</h5> <p> To enable personalized advertising (like interest-based ads), we may share your data with our marketing and advertising partners using cookies and other technologies. Those partners may have their own information they've collected about you. </p> <p> Turning off this setting won't stop you from seeing ads, but it may make the ads you see less relevant or more repetitive. </p> <p class="text-muted small"> Personalized advertising may be considered a "sale" or "sharing" of information under California and other state privacy laws. Learn more in our <a href="{$system['system_url']}/privacy">Privacy Policy</a>. </p> <div class="form-check mb-3"> <input class="form-check-input" type="checkbox" id="allow-ads" {if $user->_data['allow_ads']}checked{/if}> <label class="form-check-label" for="allow-ads"> Allow personalized advertising </label> </div> <div class="dns-actions"> <button class="btn btn-light" id="dns-cancel">Cancel</button> <button class="btn btn-primary" id="ads-save">Save Preferences</button> </div> </div> </div>

    3. Update JavaScript (inside _do_not_sell.tpl)

    Extend the script:

     
    <script> $(function() { var overlay = $("#dns-overlay"); $("#dns-trigger").on("click", function(e) { e.preventDefault(); overlay.addClass("active"); }); $("#dns-close, #dns-cancel").on("click", function() { overlay.removeClass("active"); }); // Do Not Sell / Share $("#dns-confirm").on("click", function() { $.post(site_ajax + "/do_not_sell.php", {action: "optout"}, function(response) { if(response.success) { alert("Your preference has been saved."); } else { alert("Something went wrong. Please try again."); } overlay.removeClass("active"); }, "json"); }); // Personalized Ads $("#ads-save").on("click", function() { var allow_ads = $("#allow-ads").is(":checked") ? 1 : 0; $.post(site_ajax + "/do_not_sell.php", {action: "ads", allow_ads: allow_ads}, function(response) { if(response.success) { alert("Your ad preference has been updated."); } else { alert("Something went wrong. Please try again."); } overlay.removeClass("active"); }, "json"); }); }); </script>

    4. Update AJAX Handler (do_not_sell.php)

     
    <?php require('../../../bootstrap.php'); // check ajax request is_ajax(); // user must be logged in if(!$user->_logged_in) { return_json(array('success' => false, 'message' => "Login required")); } try { switch ($_POST['action']) { case "optout": $db->query(sprintf("UPDATE users SET do_not_sell = 1 WHERE user_id = %s", secure($user->_data['user_id'], 'int'))); return_json(array('success' => true)); break; case "ads": $allow_ads = ($_POST['allow_ads'] == 1) ? 1 : 0; $db->query(sprintf("UPDATE users SET allow_ads = %s WHERE user_id = %s", secure($allow_ads, 'int'), secure($user->_data['user_id'], 'int'))); return_json(array('success' => true)); break; default: return_json(array('success' => false)); } } catch (Exception $e) { return_json(array('success' => false, 'message' => $e->getMessage())); }
Edy Lee
Admin
Joined: 2024-11-24 00:57:42
2025-09-27 01:51:49

Installation

  1. Upload the contents of the zip into your Sngine root directory.

    • includes/ajax/do_not_sell.php

    • content/themes/yourtheme/templates/_do_not_sell.tpl

    • install.sql

  2. Run install.sql on your MySQL database to add the new column:

     
    ALTER TABLE users ADD COLUMN do_not_sell TINYINT(1) NOT NULL DEFAULT 0;
     
    • In your theme footer template (_footer.tpl), include the modal:

       
      {include file="_do_not_sell.tpl"}
    • Clear cache and refresh your site.

    1. Database Update

    Extend install.sql:

     
    ALTER TABLE users ADD COLUMN allow_ads TINYINT(1) NOT NULL DEFAULT 1;

    (Defaults to 1 so personalized ads are allowed until user opts out.)


    2. Update Modal Template (_do_not_sell.tpl)

    Replace your modal content with this:

     
    <!-- Do Not Sell or Share My Personal Data --> <a href="#" id="dns-trigger" class="small text-muted">Privacy & Data Preferences</a> <div id="dns-overlay" class="dns-overlay" role="dialog" aria-modal="true" aria-labelledby="dns-title"> <div class="dns-modal" role="document"> <button class="dns-close" id="dns-close">&times;</button> <h2 id="dns-title">Privacy & Data Preferences</h2> <!-- Do Not Sell --> <h5>Do Not Sell or Share My Personal Data</h5> <p> By choosing this option, you are requesting that {$system['system_title']} does not sell or share your personal information. </p> <div class="dns-actions mb-3"> <button class="btn btn-primary w-100" id="dns-confirm">Do Not Sell or Share My Data</button> </div> <hr> <!-- Personalized Ads --> <h5>Personalized Advertising</h5> <p> To enable personalized advertising (like interest-based ads), we may share your data with our marketing and advertising partners using cookies and other technologies. Those partners may have their own information they've collected about you. </p> <p> Turning off this setting won't stop you from seeing ads, but it may make the ads you see less relevant or more repetitive. </p> <p class="text-muted small"> Personalized advertising may be considered a "sale" or "sharing" of information under California and other state privacy laws. Learn more in our <a href="{$system['system_url']}/privacy">Privacy Policy</a>. </p> <div class="form-check mb-3"> <input class="form-check-input" type="checkbox" id="allow-ads" {if $user->_data['allow_ads']}checked{/if}> <label class="form-check-label" for="allow-ads"> Allow personalized advertising </label> </div> <div class="dns-actions"> <button class="btn btn-light" id="dns-cancel">Cancel</button> <button class="btn btn-primary" id="ads-save">Save Preferences</button> </div> </div> </div>

    3. Update JavaScript (inside _do_not_sell.tpl)

    Extend the script:

     
    <script> $(function() { var overlay = $("#dns-overlay"); $("#dns-trigger").on("click", function(e) { e.preventDefault(); overlay.addClass("active"); }); $("#dns-close, #dns-cancel").on("click", function() { overlay.removeClass("active"); }); // Do Not Sell / Share $("#dns-confirm").on("click", function() { $.post(site_ajax + "/do_not_sell.php", {action: "optout"}, function(response) { if(response.success) { alert("Your preference has been saved."); } else { alert("Something went wrong. Please try again."); } overlay.removeClass("active"); }, "json"); }); // Personalized Ads $("#ads-save").on("click", function() { var allow_ads = $("#allow-ads").is(":checked") ? 1 : 0; $.post(site_ajax + "/do_not_sell.php", {action: "ads", allow_ads: allow_ads}, function(response) { if(response.success) { alert("Your ad preference has been updated."); } else { alert("Something went wrong. Please try again."); } overlay.removeClass("active"); }, "json"); }); }); </script>

    4. Update AJAX Handler (do_not_sell.php)

     
    <?php require('../../../bootstrap.php'); // check ajax request is_ajax(); // user must be logged in if(!$user->_logged_in) { return_json(array('success' => false, 'message' => "Login required")); } try { switch ($_POST['action']) { case "optout": $db->query(sprintf("UPDATE users SET do_not_sell = 1 WHERE user_id = %s", secure($user->_data['user_id'], 'int'))); return_json(array('success' => true)); break; case "ads": $allow_ads = ($_POST['allow_ads'] == 1) ? 1 : 0; $db->query(sprintf("UPDATE users SET allow_ads = %s WHERE user_id = %s", secure($allow_ads, 'int'), secure($user->_data['user_id'], 'int'))); return_json(array('success' => true)); break; default: return_json(array('success' => false)); } } catch (Exception $e) { return_json(array('success' => false, 'message' => $e->getMessage())); }
ScriptsTribe https://scriptstribe.com