The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Generating a Random String - PHP code

Labels

This Discussion is public

Notifications

I used the following code to generate a default Random String in a field:

add_filter('frm_get_default_value', 'my_custom_default_value', 10, 2);
function my_custom_default_value($new_value, $field){
if($field->id == 231){ //change 231 to the ID of the field
$length = 10; //change to the string length desired
$randomString = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);

$new_value = $randomString;
}
return $new_value;
}

Thanks for this :)

This is cool, but where do you use the shortcode and with what syntax?

Discussion closed.