Frontend Form for Custom Post Type
Have you tried changing Line 83? Change ‘post_type’ => ‘post’, to ‘post_type’ => ‘YOURCUSTOMCPT’, See Codex article for wp_insert_post for reference – codex.wordpress.org/Function_Reference/wp_insert_post
Have you tried changing Line 83? Change ‘post_type’ => ‘post’, to ‘post_type’ => ‘YOURCUSTOMCPT’, See Codex article for wp_insert_post for reference – codex.wordpress.org/Function_Reference/wp_insert_post
thanks to @TheDeadMedic, I found the solution. I used reserved terms, and that’s why WordPress interpreted my inputs as query parameters. so for example with my categorys, I had to change my classes in my form : ‘post_category’ => array($_POST[‘cat’]), // Usable for custom taxonomies too by ‘post_category’ => array($_POST[‘my_cat’]), // Usable for custom taxonomies … Read more
No, it’s not okay to lock down or block access to wp-admin and/or it’s sub-directories. Not only you already mentioned this is a crude method, it could and most likely will break the site, depending on its theme/plugins. The reason is that some plugin or themes depend on either admin-ajax.php or admin-post.php to accomplish some … Read more
If someone has a better solution, I’m open to it, however, what I came up with seems to work fine. Basically the following code is just waiting for the image to finish uploading and then hooking into the add_attachment action. Once the first is added, we hook in and then generate the new images via … Read more
I think you are referring to two different things.. 1) Verifying the request. You should be using WP Nonces to verify the request and protect it against XSS. That should be a practice for all your forms. you could also add additional layer of security by integrating a reCAPTCHA. 2) Data Encryption when you attempt … Read more
WordPress supports only datepicker. If you want to add timepicker in datepicker you have to use jquery-ui-timepicker-addon as extension in your theme or plug-in. Add css and js as below add_action(‘wp_enqueue_scripts’, ‘custom_datepicker’); function custom_datepicker() { //wp_enqueue_script(‘jquery-ui-datepicker’); //wp_enqueue_script(‘jquery-ui-core’); wp_enqueue_script(‘jquery-ui-timepicker-addon’,get_stylesheet_directory_uri().’/js/jquery-ui-timepicker-addon.js’,array()); wp_enqueue_style(‘jquery-ui-timepicker-addon’,get_stylesheet_directory_uri().’/css/jquery-ui-timepicker-addon.css’,array()); wp_enqueue_style(‘jquery-ui’,get_stylesheet_directory_uri().’/css/jquery-ui.css’,array()); } You can download all css and js files from this link http://trentrichardson.com/examples/timepicker/ Call timepicker … Read more
You want to submit the data to admin_post_(action) and then handle the request. You may need jQuery to intercept the click and supply all the required data, but this shows you the main parts. HTML <form action=”http://www.example.com/wp-admin/admin-post.php” method=”post”> <input type=”hidden” name=”action” value=”add_foobar”> <input type=”hidden” name=”data” value=”foobarid”> <input type=”submit” value=”Submit”> </form> PHP add_action( ‘admin_post_foobar’, ‘prefix_admin_foobar’ ); … Read more
My gut instinct would be to roll my own AJAX callback. You obviously know the post ID (since you have it on the front end) and the names of the fields, just post that back to WP using AJAX and programmatically set the values there. An untested example (props to Kailey Lampert): // Add checkboxes … Read more
Rarely do I answer question with simply a plugin recommendation – and I’d never recommend a commercial one – but since there’s a really good plugin for the task of front end profiles/login and such out there, I cannot let it go unmentioned: Check out Theme-My-Login by Jeff Farthing. There ain’t no better solution. It’s … Read more
As you haven’t offered the details on what you’re after, I’ll try to grab them all very briefly. Use the API – public WP_User_Query API functions Basically get_user_by() should be enough for you. Let’s say you fire of your form and the input field name was user_id. So you’d just retrieve the value from the … Read more