Using Token for Views

By: Walter Jones | Asked: 02/08/2023
ForumsCategory: General questionsUsing Token for Views
Walter JonesWalter Jones asked 1 year 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 1 year ago

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

Walter JonesWalter Jones replied 1 year ago

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

2 Answers
Walter JonesWalter Jones answered 1 year ago
Anyone find anything wrong with this code?  
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;
  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
Walter JonesWalter Jones replied 1 year ago

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

Bobby Clapp replied 1 year ago

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

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