Trying to save custom post type from frontend partially working
Have you tried TDO Mini Forms? It allows users posting content from the frontend. I don’t know if it allows submitting custom types, but at least can give you a hint.
Have you tried TDO Mini Forms? It allows users posting content from the frontend. I don’t know if it allows submitting custom types, but at least can give you a hint.
try something like this: <?php $taxonomies = array( ‘wissen_tags’ ); $args = array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => false ); $terms = get_terms($taxonomies,$args); if (count($terms) > 0): i = 0; foreach ($terms as $term): ?> <div class=”wissen_tag_list”> <input type=”radio” value=”<?php echo $term->term_id; ?>” name=”wissen_tags” class=”wissen_tag_list_ckb” <?php if ( $i == 0 ) … Read more
wp_update_term() doesn’t changes taxonomy. It just updated the existing taxonomy. Say the below code- $update = wp_update_term( 1, ‘category’, array( ‘name’ => ‘Uncategorized Renamed’, ‘slug’ => ‘uncategorized-renamed’ ) ); if ( ! is_wp_error( $update ) ) { echo ‘Success!’; } This code finds the category which ID is 1, then updates it to the name … Read more
I believe it is better if you use the ajax method instead of sending the POST to the same page. You can use javascript to increment the form / fieldset. Use an array for the name e.g <input type=”text” name=”ingredient[]”/> If you want to edit the post, just you us the saved data on the … Read more
You have to localize script by using wp_localize_script function. In the admin side ajaxurl is already available. But in front end you have to localize script to define ajaxurl. Example: wp_enqueue_script( ‘custom-ajax-request’, ‘/path/to/settings.js’, array( ‘jquery’ ) ); wp_localize_script( ‘custom-ajax-request’, ‘MyAjax’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ) ) );
A simple user meta row can handle that for you (the second issue), you can store the post id and the vote (up/down) in an array and that is just the same as post meta ex /** * update user vote per post * @param int $user_id * @param int $post_id * @param mixed $vote … Read more
Use following code to achieve your requirement. //hook when user registers add_action( ‘user_register’, ‘myplugin_registration_save’, 10, 1 ); function myplugin_registration_save( $user_id ) { // insert meta that user not logged in first time update_user_meta($user_id, ‘prefix_first_login’, ‘1’); } // hook when user logs in add_action(‘wp_login’, ‘your_function’, 10, 2); function your_function($user_login, $user) { $user_id = $user->ID; // getting … Read more
It is really not best practice to do it this way at all. In fact you don’t need to create an ajax.php file unless you’re just going to include it in your functions.php file. You need to read up on AJAX in WordPress. You would just add an action on ‘wp_ajax_name_of_action’ and just specify the … Read more
add below code after echo $attach_id…. set_post_thumbnail( $post_id , $attach_id);
That’s beacuse you are calling wp_redirect after you have some buffer output from your code. you should change the order of the template functionally, meaning that first check if the form has been submitted and then show the page, so try something like this: <?php /* Template Name: Submit Work */ ?> <?php // Check … Read more