Using Token for Views

By: Walter Jones | Asked: 02/08/2023
ForumsCategory: General questionsUsing Token for Views
Walter JonesWalter Jones asked 2 years ago
I swear there is a tutorial running around related to using a token as an extra layer of security for views…can someone point me in the right direction? Looking for something quick so I don’t have to reinvent the wheel. 
Victor Font replied 2 years ago

I’m pretty sure it’s Bobby’s.

Walter JonesWalter Jones replied 2 years ago

That’s what I thought, I just can’t find it 😤

2 Answers
Walter JonesWalter Jones answered 2 years ago
Anyone find anything wrong with this code?  
<script>
const random = (length = 8) => {
// Declare all characters
let chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
//Pick characters randomly
let str = '';
for (let i = 0; i < length; i++) {
str += chars.charAt(Math.floor(Math.random() * chars.length));
}
return str;
if(!jQuery('#field_entrytoken').val()){
  jQuery('#field_entrytoken').val(random(20)); //Change 20 to any numerical value you want for the amount of characters to apply to the "Entry Token". The more characters that you use, the less likely it will be cracked
}
}
</script>
Walter JonesWalter Jones replied 2 years ago

Its not populating a token in the field, is why I am having yall look at it.

Bobby Clapp replied 2 years ago

You have an extra last } that compared to my code.

https://www.diffchecker.com/irBrTTYU/

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right