Could you provide some example code for it?
This is so urgent…
Hi Yakub,
Sorry, the title is somewhat in contradiction with the description. What exactly you need: (1) to auto upload image to a specific category or (2) to allow non-admin users to upload images and assign them to categories?
Regards,
-Nadia
Now I want to upload image not in admin panel.
I have create media category called as “MyMedia”.
So I want to move images that any user uploaded.
Now I am implementing this, but some difficult.
I have used function wp_set_object_terms, but it not works.
Please help me.
Yakub,
Since I don’t quite understand your task, the common information:
add_action( 'add_attachment', 'your_prefix_add_attachment' );
function your_prefix_add_attachment( $post_ID ) {
$term_ids = array( 14 ); // ID of your "MyMedia" category to assign to the uploading media file
$taxonomy = 'media_category'; // taxonomy name
wp_set_object_terms( $post_ID, $term_ids, $taxonomy, false );
}
This code will add any uploaded image to media category with the ID 14.
Hope this helps.
-Nadia
OK. It works. Many thanks.