Private ID – change to numeric number
-
Is it possible to set the Private ID to only use numbers not numbers and letters?
-
I don’t have a filter built in to the plugin for that purpose, so you’d have to modify the plugin directly to do that, which I don’t support. Alterations to the plugin code will be deleted with any update, so you’ll have to be careful of that.
Can I not just restrict the character set to numbers at the creation of the Private ID or is it more complicated than that? I assume there is a random statement in there some ware that picks from a list of charioteers. I’m happy to adjust this single line to achieve that if that works and manually update the same line in future updates. Assuming I can work it out in the first place.
The purpose for asking is I would like the use the Private ID as a pin for a telephone service you can only register once for.
An alternative Idea is to add an additional field and generate a random number but like the Private ID this would have to be unique in the database. Is this possible?
I think this plugin is virtually perfect for the task I am looking to use it for and have been looking for a few years now. The last bit of the jigsaw is the ID.
Thanks
If you’ve got some PHP skills, you can create a custom ID field using a function that generates the value each time a new record is created. You’d use the ‘pdb-after_submit_signup’ and ‘pdb-after_submit_add’ hooks to trigger your function to generate and save your unique ID.
Altering the internal function that generates the Private ID is not complicated at all, it’s just not a recommended way to do what you want to do.
Thanks for the reply
Not recommended because any changes will be overwritten and breaks support? Or is there more reasons?
I found where to remove the A-Z and also adjust the length which generates a perfect result for me.
Thanks
Yes, I don’t support it, so if you run into problems, you’re on your own. Also, you will lose your changes every time you update the plugin, and that can be problematic in the long run.
I have a new filter that will help you in the upcoming release, so you can use a filter callback to do this when that comes out.
I see you have added an extra filter for the private id. Thanks for the consideration.
How do you use it?
Thanks
It’s very simple, the filter passes in the private ID that the application generated, you just return the private ID that you want to use. It will check it for a duplicate in the database, and if the ID already exists, it will go through the process again. You have to make sure your function generates a different value each time it’s called or it will go into an endless loop.
Thanks for the reply. Before this update I was able to just adjust the participants-database.php and alter the length of the private pin from 5 to 6 and remove A-Z as charioteers to use. The result was a 6 digit random number I could print to screen after registration and also have sent in an email.
I can’t see how or what I would need to adjust to make a private ID 6 digits long and only numbers.
How would I achieve the same functionality?
Thanks
londonnet,
How did you use the filter? Where is it? Sorry, I know very little about filters etc.!
I edited participants-database.php to change the length of the PID (5 characters ‘looks’ too insecure) by changing 5 to something bigger (such as 12) in
public static $private_id_length = 5;
But I get a length of only 6 whatever number (6 or greater) I put in!Thanks
- This reply was modified 7 years, 9 months ago by humpty2.
I have no idea. and the new version no longer has this setting by the look of it.
I would like to know the following:
How to change the length of the Private ID
How to set the plugin to only use digits and not alphanumeric.Both of these things are tested and working in the current version. You do need to understand how to use WordPress filters and write PHP functions.
If you are creating your own private ID generator, you simply need to set up your generator function on the filter, like this:
add_filter( 'pdb-generate_private_id', 'my_private_id_generator' ); function my_private_id_generator( $pid ) { // generate your private id here... return $pid; }
Thanks for the idea. I feel the previous method of adjusting the participants-database.php was a lot easier for a user of my level to pick up.
For a future update would it be possible to simply have some variables that could be set in the settings section and keep the generation of the id and the clever parts in the plugin?
If I had any PHP skills I would’t need plugins
Thanks
I second that!
1. Choose length
2. Choose Alphabetical/Numerical/Alphanumerical
- The topic ‘Private ID – change to numeric number’ is closed to new replies.