• Hello everyone,

    I want to build a plugin, nothing weird there, but I want to build it in a way that the plugin gives you a submenu page with some initial option fields to fill, and then, when the user fills the fields, the plugin will automatically generate a set of fields to add more information.

    For example:

    The plugin I want to build is to generate and edit the info of a sports league.

    You enter the submenu page, the plugin will ask you to give it the number of teams in your league, how many weeks the current season will last and how many games every team will play in the season, form there, the plugin will automatically generate the season calendar, and that calendar will be editable to place game scores and other info, also the plguin will generate a section (inside the same submenu page) for every team, and in that section you will be able to edit the team’s roster and players info.

    This can be achieved creating custom post types for seasons, games, teams and players, but I’m trying to find an alternative to that beacuse of two reasons, the first one is that following that approach I’ll have to use a lot of custom metaboxes and custom fields, and I don’t want to have to redo all of that once Gutenberg is integrated with the WP core. The second one is that, in my experience, when a plugin has many interconected custom post types, it gets complicated for the user.

    Remember the above is just an example to make things more clear, don’t pay much attention to the technical details to build that.

    My question is: if I want to have all of the information in a submenu page and store it in the options meta, is a good or bad idea and why?
    Is there an alternative to achieve that without using custom post types?
    If, eventually, I want to put that plugin in the WP plugin repository, will it be rejected because of some broken rule?
    Can you list some advantages or disadvantages for both (or any other) approches?

    Thank you in advance for the answers, hope I made myself clear.

    M

Viewing 1 replies (of 1 total)
  • Yes you could store your settings in the options table. You could also shoehorn your structured data there too, BUT I would strongly advise against this and direct you to create supplementary tables instead.

    To continue your sports analogy, I can envision storing data such as: agegroup / teamname / district / year, and for each of these having a host of match+results such as: ground / round / referee / hometeam / awayteam / result. If you jam these into the options table you will have restricted database keys into this data, make your life easy and the app scalable by creating your own tables.

    Rather than use custom post types, I would be using custom page templates where required, granted this pushes you into the direction of using a child theme, but it may not be necessary.

    I would use shortcodes to access your plugin code.

    Each of your system users (team/score clerk/coordinator etc) would have their own WordPress login, at subscriber level. Using either user_meta or a custom table give each of them a sports role attribute, then your shortcodes can enforce access and permission capabilities. Harden your updates from being hacked by incorporating a hash of data keys and a session nonce, and be sure to check it.

    Provided your plugin is well documented as to its database resources, and providing it has good manners such as options to keep or delete the custom tables on uninstall etc, it would be accepted into the plugins repository. Things to watch are that you follow conventions such as use the table prefix, make your shortcodes distinct (so not [results] but [lgs_results]), and that you correctly sanitize user input prior to forming SQL commands and submitting them to the database.

    I have created a few apps along these lines though have not released them, so far I do still do some of the admin manually in SQL rather than doing the extra code, so I have only created roles of participant and judge as I am the contest convener. Initially I did forms with an update button, more recently I use AJAX and log updates continuously.

    • This reply was modified 6 years, 3 months ago by RossMitchell.
Viewing 1 replies (of 1 total)
  • The topic ‘Settings Options instead of CPT and custom fields’ is closed to new replies.