How can I approve uploaded images in wordpress.
I am not asking for the code but general.
I have done research. It works only for comments.
My Code
<form method="post" enctype="multipart/form-data">
<input type='file' name='file'>
<input type='submit' value='send'>
</form>
upload();
function upload(){
require_once( ABSPATH . 'wp-admin/includes/image.php' );
require_once( ABSPATH . 'wp-admin/includes/file.php' );
require_once( ABSPATH . 'wp-admin/includes/media.php' );
$attachment_id = media_handle_upload( 'file');
//No error when submit button is pressed with file
if ( is_wp_error( $attachment_id ) ) {
echo 'BIG TIME ERROR';
} else {
echo 'BIG TIME SUCCESS';
}}}
For all the data (if there is any) and the file, you’ll need to store as a custom post type:
http://codex.wordpress.org/Post_Types
If you mark each of those post types as Draft when they’re created than the WP admin will need to go in to the admin system and moderate them by publishing any that are ok, and deleting others.
You can then loop through all of your custom post types knowing that any that you can access have been published.
This may also be of use:
https://wordpress.org/plugins/user-submitted-posts/