Below is a question I would like to ask the WPQuestions community.
For the work I am asking, is $100 an appropriate prize amount or is this really custom development territory?
<strong>Front-end post creation and editing page template</strong>
Please can someone provide full working code for a page template that contains a standard HTML form to create and edit custom post types from the front-end of my website.
This question is a continuation of a [[LINK href="http://www.wpquestions.com/question/showChrono/id/9977"]]previous post here on WPQuestions[[/LINK]]. I’ve created a working solution (90% complete) using Formidable Forms Pro, but would like to drop the plugin dependency.
A dependency solution I would consider however (if actually possible???) is the use of WebDevStudio’s CMB2 framework to achieve the goals outlined below.
I have four custom post types and would like the ability to tweak the supplied code to produce creation/update page templates for each of my four custom post types.
My four Custom Post Types are: <strong>News</strong>, <strong>Events</strong>, <strong>Questions</strong> & <strong>Classifieds</strong>.
All post types support <strong>title</strong>, <strong>content</strong>, <strong>excerpt</strong>, <strong>author</strong> & <strong>comments</strong>.
All post types, <em>except</em> Questions, support a <strong>featured image</strong>. An upload field that only allows the attachment of JPG, PNG and GIF images of less than 2MB is required.
The user must be able to upload a new featured image or delete a featured image completely.
A preview of the featured image should be supported on the front-end.
Uploaded images should be stored in the uploads folder.
An author must be able to switch comments ON or OFF when creating and editing their post entry.
Authors must be registered and logged in to create a post.
The author of a new post should be the logged in user. Authors can only edit their own posts.
Editors and Administrators should be able to edit any entry from the front-end.
<strong>Required fields</strong> are title, content, author and comments on/off. A custom message should be displayed if a field fails validation.
The title field must be no longer than 100 characters. Again, a custom message should be displayed if this requirement is not met.
My Events custom post type features three custom fields - <strong>event_date</strong>, <strong>event_start_time</strong>, <strong>event_finish_time</strong>. These fields need to feature on the Event creation and update form.
event_date & event_start_time are required fields.
The event_date field should support a jQuery date picker.
The event_start_time and event_finish_time fields should support jQuery time pickers.
Dates and times should be stored as UNIX time stamps if possible. I need the ability to sort by date and time meta information in custom query’s.
The form that creates/edits <strong>Events</strong> should support a <strong>tag-type custom taxonomy</strong> of <em>event-type</em>.
The form that creates/edits <strong>Questions</strong> should support a <strong>tag-type custom taxonomy</strong> of <em>question-type</em>.
<strong>Classifieds</strong> should support a <strong>category-type custom taxonomy</strong> of <em>classified-type</em>. The user should only be able to select one <em>classified-type</em>.
Users should see standard HTML form fields when creating and editing posts. TinyMCE integration is not required. Post content should be stripped of any HTML tags.
All form data should be escaped and sanitised.
When created, <strong>Questions</strong> and <strong>Classifieds</strong> are <em>published immediately</em>. The author should be redirected to the new post. The new post should feature an Edit button that takes users back to the page template form to edit/update their entry.
<strong>News</strong> and <strong>Events</strong> are saved with a post status of “Draft” when first created.
An Editor or Administrator must review and publish News and Event entries. Once published, the original post Author is free to perform post edits as normal.
After a News or Event post is created, the author is shown a message to say their submission is awaiting review and publication.
After updating any published post type, the user is re-directed to the updated post entry.
The post entry should feature a delete option. Delete functionality should be restricted to the original post Author, Editors and Administrators.
Security, validation and sanitisation should be important considerations in any supplied solution.
Standard WordPress functions and bundled libraries should be used wherever possible.
Hi, I just want to mention an alternative approach: <strong><strong>theming the backend for these users.</strong></strong>
I've seen a custom themed backend that looked the same as the front-end, so editing a post looked like front-end editing.
So most of the work would be in CSS/JS? instead of PHP, I imagine.
There are many plugins out there to theme the backend, so you could check some of them out to get an idea how to do it:
Here's another list of these kind of plugins:
Great suggestion, thanks Dbranes.
Sure there are trade-offs going this route:
- You would also have to adjust your CSS code to the HTML changes of the backend, as WordPress evolves.
- It might also depend on how complex your front-end is, if one would like to do this.
but in general you would just enqueue a CSS/(JS?) file in the backend with few lines of PHP.
... and many prefer working with CSS/JS instead of PHP.
There are many great plugins out there for front-end editing, but they can of course affect the security of your install, like any other plugin. Will they be supported after 1 year, 2 years, who knows?
If you're are a CSS/JS guy, then maybe this could be an alternative, where you could work on this yourself instead of hiring a PHP WordPress developer.
... well, that's my 2 cents ;-)
Thanks for the excellent suggestions Dbranes.
When I began this project my first thought was, as you've suggested, to offer a highly customised of the Admin area. I'm pretty proficient at theming the backend (without the use of plugins) so thought this made sense as I'd be leveraging all the existing WordPress security and validation features.
The more I thought about it however, the more it seemed to make sense to go with a front-end forms approach. I really didn't need/want the user to access the standard WordPress backend in at all. The big problem I have with a forms approach is the plugin dependency and extra database overhead - post creation and editing still required a separate form entry for post management.
At the end of the day I think what I'm really after is some custom code to create front-end post management forms. No plugin dependency, just some nice clean code for a very specific task. How this work is properly scoped and priced is the primary question now I suppose.
A big thanks for your time, effort and thoughts to date.
John Cotton answers:
If I can change the question to "would I do all that for $100" the answer is no.
There are sufficient unknowns in your requirements that briefing time alone would be worth that prize.
OK, thanks John.
John Cotton comments:
If I can just make an observation on Dbranes suggestion....
If you have experienced users, then the WordPress dashboard is great.
But the minute you want to start hiding things (or making them work for novices), you're creating trouble for yourself.
Also, those admin CSS plugins need to be kept up to date.
If you editing needs are very specific (and it sounds like yours are), front end editing is by far the best. And the code is very straightforward. The API/Codex gives you plenty of structured calls, you just need to connect them together.
Thanks for the follow-up John.
I'm pretty sure a custom forms-based approach is what I really need to follow in this instance (see my reply to Dbranes above).
The question then becomes, how should this work be scoped and priced? Are we talking more like $200, $300, $400, $500 for this type of custom development? I just don't know sorry.
Cheers for all your suggestions to date.