Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author DBAR Productions

    (@dbar-productions)

    The short answer is YES, IF you are good with PHP programming.

    My plugin has a LOT of action and filter hooks throughout the code to make it relatively “easy” to extend the functionality without having to directly modify the code. That would be the preferred way to go — tap into those hooks with a custom plugin of your own that extends the functionality. If you do it via the hooks and your own plugin (or custom code in your theme’s functions.php file), then you could still update the main plugin without losing what you do.

    However, none of this is as simple as many people think, especially if you don’t have much programming experience.

    I’m guessing that there is some other field you want to have on the sign-up form that volunteers need to fill in?

    While it is not that difficult to use one of the many filter hooks in the function that outputs the form to add your own form field, there is MUCH more that needs to happen! You first need to validate and sanitize that data after the form is submitted, which would required tapping into another hook in the form processing function. Then you actually need to save that data somewhere, which would require either modifying the signups database table to add an extra field, and then writing the SQL function to save that data, or else figuring out some other way to save that data. Then, what are you going to do with that data? There would be a LOT of other functions you would have to tap into in order to retrieve and display that information in various places (on the task list? in emails? on the admin view signups page, etc.). Best practices also need to be followed for escaping all output that goes to the screen from the database or user inputs, as well as making sure everything is validated and sanitized on the way in (form processing), etc., so you don’t leave your site open to hackers.

    So, in short, I can’t really point you to just one file that you can modify, as there would be several that you would need to modify, or hook into, if you are trying to do what I have described. You can get a brief idea of just how much work is involved by looking at the class-pta_sus_public.php file, which is responsible for most of the public side output. The data.php file handles most of the database operations, while class-pta_sus_emails.php handles email functions, and class-pta_sus_admin.php handles most of the admin side of the plugin. The main pta-volunteer-sign-up-sheets.php file gets everything set up and initialized, including the configuration of the database tables (or any database table updates when changes are made).

    Thread Starter bek86

    (@bek86)

    Thank you for your reply…

    What if I had to add a simple dropdown to the form?
    According to your suggestions, I should add the field to class-pta_sus_public.php, store it on db in data.php and to output it on emails in class-pta_sus_emails.php file.

    Am I missing anything?

    Plugin Author DBAR Productions

    (@dbar-productions)

    That’s an extremely simplified version of what you need to do. There are many places throughout the code that you will need to modify for the new field. If you are good with PHP, you should be able to follow through the code and see what is done for all the other fields, and do something similar.

    Without looking through the code myself, from memory, here are just a few of the things you will need to do:

    Even a “simple dropdown” needs to be validated and sanitized before saving in the database (if you don’t want your site hacked), and you also need to set up the extra column in the appropriate database table (setup in the main plugin file), and increment the database version number, add that field to the allowed fields list (in data.php), add the appropriate type to the sanitize and validate functions to check for only allowed values (there is currently no dropdown fields in the form, so that’s a “type” that you would have to add, and then create the necessary validation and sanitizing functions). Then, you need to make sure that all database functions the save or get fields from the tables work correctly with your new field, then go back through the main public file and check all the places where data is displayed and add the appropriate code to output the field in the tables, etc. If you want it to be in emails, then you need to edit the emails class file as well. If you want admin to be able to see it, then you also need to edit the list table class that displays the signups on the admin side. Then, if you want it to also be in the CSV files for exporting, you’ll need to edit that file also.

    That’s just a few of the things I can think of off the top of my head. Perhaps you already know all of this and are prepared to do all the searching and needed code changes and extensive testing. Most people do NOT know all of the things that are involved to add one “simple” field to a form, and get frustrated when they make feature requests for what they think is a very simple change and I have to explain to them how much work is really involved.

    Thread Starter bek86

    (@bek86)

    I’ll give it a try…

    Thank you for your explanations and your time!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Extend sign up form’ is closed to new replies.