Hub Hack: Block Free or Personal Email Addresses on Form CTAs

Follow

Use this Custom Code snippet to prevent Hub visitors from entering non-work emails when submitting Form CTAs.


 

Details

  • Type: JavaScript
  • Placement: Body Bottom
  • Notes: Choose between two options: block emails from both a predefined list of free domains plus a list of domains you specify; or block emails from just a list of domains you specify. In either case, clicking on Submit on a Form CTA after entering an email from a blocked domain will return the error message "Please enter a valid work email". Both options

 

Code

Option 1: Block Free Domains & Specified Domains

This will block emails from a predefined list of domains (see the full list here) as well as domains you have specified (such as competitor domains).

To specify domains, replace DOMAIN1.COM, DOMAIN2.NET, etc. in the code below. You can list as many domains as you want. Add more domains by separating with a comma, and enclose all domains within double quotation marks, e.g. "anotherdomain.com","yetanotherdomain.org". If you don't want to specify custom domains and use only the predefined list, leave this section unchanged.

<script>
/* Prevent CTA Submit for both free domains and specified domains */
$.getScript('//cihost.uberflip.com/plugins/block-emails/script.js')
.done(function( ) {
/* Additional domains to block */
window.domains.push("DOMAIN1.COM","DOMAIN2.NET");
});
</script>

 

Option 2: Block Specified Domains Only

This will block emails only from domains you have specified (such as competitor domains). Emails from domains not explicitly specified in the script will be allowed.

To specify domains, replace DOMAIN1.COM, DOMAIN2.NET, etc. in the code below. You can list as many domains as you want. Add more domains by separating with a comma, and enclose all domains within double quotation marks, e.g. "anotherdomain.com","yetanotherdomain.org".

<script>
/* Prevent CTA Submit for specified domains only */
$.getScript('//cihost.uberflip.com/plugins/block-emails/script.js')
.done(function( ) {
/* Domains to block */
window.domains=["DOMAIN1.COM","DOMAIN2.NET"];
});
</script>

 

Variation: Restrict to Specific Streams or Items

If you want to activate this Hub Hack only on selected Streams or Items, use one of the snippets below instead. To use, insert the code from Option 1 or Option 2 above on the line that reads /* Replace this line with code from Option 1 or Option 2 */. When copying the code from Option 1 or Option 2, do not include the <script> or </script> tags — just the code in between.

Restrict To Specific Streams

To specify Streams, enter their Stream IDs in the format 'stream-####', replacing #### with the numerical Stream ID.

Find Stream IDs under Hubs > Content > Streams tab > open Stream > Metadata tab.

<script>
Hubs.Events.on('ctaActivate', function(){
    /* To add Stream, use 'stream-####'; separate multiple with comma */
    var itemIdArrayCtaDomainBlock = ['stream-####','stream-####'];
    itemIdArrayCtaDomainBlock.filter(function (itemID) {
    document.body.classList.contains(itemID);
}); {
/* Replace this line with code from Option 1 or Option 2 */
}
});
</script>

Restrict To Specific Items

To specify Streams, enter their Item IDs in the format 'item-####', replacing #### with the numerical Item ID.

Find Item IDs under Hubs > Content > Items tab > open Item: look at the URL; the middle string of numbers is the Item ID, e.g.

https://app.uberflip.com/hubs/itemEditContents/123457/123456789/1234567.

<script>
Hubs.Events.on('ctaActivate', function(){
    /* To add Stream, use 'item-####'; separate multiple with comma */
    var itemIdArrayCtaDomainBlock = ['item-####','item-####'];
    itemIdArrayCtaDomainBlock.filter(function (itemID) {
    document.body.classList.contains(itemID);
});
/* Replace this line with code from Option 1 or Option 2 */
}
});
</script>
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.