Title: shortcode to random number function returns same number
Last modified: July 7, 2020

---

# shortcode to random number function returns same number

 *  Resolved [macnmotion2](https://wordpress.org/support/users/macnmotion2/)
 * (@macnmotion2)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/shortcode-to-random-number-function-returns-same-number/)
 * ***RESOLVED***
    If I force refresh the form page after submitting the form and
   then submit the form again, I get updated random numbers. I’ll have to force 
   a refresh after the form is submitted to ensure this doesn’t happen.
 * I have a simple function, and created a shortcode.
    ———–
 *     ```
       function uniquenum_function() {
   
   
           $uniqueNum = rand(10000,99999);
           return $uniqueNum;
   
       }
   
       add_shortcode('uniquenum', 'uniquenum_function');
       ```
   
 * ———–
    When I call the function from a page template and keep refreshing a page,
   I get a new random number each time.
 * However, when I add the shortcode into my Contact Form 7 form using a hidden 
   dynamic field and submit multiple forms, I get the same random number every time.
 * I’m having the same issue if my function returns a timestamp. I get the same 
   timestamp over and over.
 * Anyone know why the value I’m returning from the function is “sticking” and repeating
   each time I submit the form? Is this some type of caching issue?
    -  This topic was modified 5 years, 11 months ago by [macnmotion2](https://wordpress.org/support/users/macnmotion2/).
    -  This topic was modified 5 years, 11 months ago by [macnmotion2](https://wordpress.org/support/users/macnmotion2/).

The topic ‘shortcode to random number function returns same number’ is closed to
new replies.

 * ![](https://ps.w.org/contact-form-7-dynamic-text-extension/assets/icon-256x256.
   png?rev=3019574)
 * [Contact Form 7 - Dynamic Text Extension](https://wordpress.org/plugins/contact-form-7-dynamic-text-extension/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7-dynamic-text-extension/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7-dynamic-text-extension/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7-dynamic-text-extension/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7-dynamic-text-extension/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7-dynamic-text-extension/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [macnmotion2](https://wordpress.org/support/users/macnmotion2/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/shortcode-to-random-number-function-returns-same-number/)
 * Status: resolved