Hi Tareq, thanks for this great plugin!!
I need some help, im trying to make it works without success, i need to add a custom taxonomy (im using taxonomy manager, my taxonomy name is “provincias”)
i added this function to my functions.php :
function wpufe_taxonomy( $post_type, $post = null) {
wp_dropdown_categories( ‘show_option_none=’ . __( ‘– Select –’, ‘wpuf’ ) . ‘&hierarchical=1&taxonomy=provincias&hide_empty=0&orderby=name&name=provincias&id=cat&show_count=0&title_li=&use_desc_for_title=1&class=cat requiredField&exclude=’ . $exclude );
}
after that i add this in functions.php :
add_action( ‘wpuf_add_post_form_description’, ‘wpufe_taxonomy’, 10, 2 );
after that this:
if (function_exists(‘wpufe_taxonomy’)) {
add_action(‘wpuf_add_post_after_insert’, ‘save_taxonomy_data’);
}
at the end i added this to the same functions.php file:
function save_taxonomy_data($post_id) {
// verify this came from our screen and with proper authorization.
if ( !wp_verify_nonce( $_POST['taxonomy_noncename'], __FILE__ )) {
return $post_id; }
// verify if this is an auto save routine. If it is our form has not been submitted, so we dont want to do anything
if ( defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE )
return $post_id;
// Check permissions
if ( ‘post’ == $_POST['post_type'] ) {
if ( !current_user_can( ‘edit_page’, $post_id ) )
return $post_id;
} else {
if ( !current_user_can( ‘edit_post’, $post_id ) )
return $post_id;
}
// OK, we’re authenticated: we need to find and save the data
$post = get_post($post_id);
if ($post->post_type == ‘post’) {
$select_name = $_POST['provincias'];
wp_set_object_terms( $post_id, $select_name, ‘provincias’ );
}
}
So, i can see the taxonomy (provincias) dropdown in the creation of a new post from frontend, but when i save, the selected taxonomy doesnt get saved.
Something is missing or bad coded?