Skip to content

Instantly share code, notes, and snippets.

@tahmid-ul
Last active November 10, 2022 03:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tahmid-ul/d42437810cba689bc50496f94106c05a to your computer and use it in GitHub Desktop.
Save tahmid-ul/d42437810cba689bc50496f94106c05a to your computer and use it in GitHub Desktop.
Smart shortcode to generate unique 5 digit number
/*
* Add the smartcode to the list
*/
add_filter('fluentform_editor_shortcodes', function ($smartCodes) {
$smartCodes[0]['shortcodes']['{5_digit_unique_id}'] = 'Unique ID (5 digit)';
return $smartCodes;
});
/*
* Transform the smartcode
*/
add_filter('fluentform_editor_shortcode_callback_5_digit_unique_id', function ($value, $form) {
$digits = 5;
return rand(pow(10, $digits-1), pow(10, $digits)-1);;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment