Skip to content
Advertisement

Generate unique code every six hour with wordpress rest api

I want to generate 12 digit unique code with wordpress rest api which refresh every six hours. I didn’t find any code or method for my requirement.

Example URL: ….domainname.com/wp-json/astra-sites/v1/get-last-unique-code

Json code on above link:

JavaScript

This code refresh every six hours. Please give me code or details to generate same code which refresh every six hours.

I know how to do custom “register_rest_route” to create custom api path but I didn’t find any method to refresh code automatically with php and wordress.

I am using below code

JavaScript

Above code generates unique code but I don’t know how to store it in database which refresh every six hours. I tried update_option() method but it doesn’t work.

Thank you.

Advertisement

Answer

Executed below updated code snippet of yours. When you run SITE_URL/wp-json/my-custom-pages/v1/get-last-unique-code you will find the value of your checksum which will be updated every six hours

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement