I want, by admin approval, that a logged in user can upload a image and add to the post which is posted by other user. He should add the image to the post from the Front-End.

  • 1
    Why does it seem that questions like these are asked by freelancers promising things to clients and then asking WPSE to write all the code for them? Preferably ASAP. – Marc Dingena May 31 '13 at 7:36

This is a way to add post images and other things. So put different check on it according to your need.

    if( 'POST'  == $_SERVER['REQUEST_METHOD' ] && !empty( $_POST['action' ] ) &&  $_POST['action' ] == "new_post") {
                if (isset ($_POST['post_title'])) {
                        $post_title =  $_POST['post_title'];

            $post = array(
                        'post_title'    => $post_title,
                        'post_content'  => $post_content,
                        'post_category' => array($post_category),
                        'tags_input'    => array($post_tags),
                        'post_status'   => 'draft',
                        'post_type' => 'post'

                $post_id = wp_insert_post($post);
                wp_set_post_tags($post_id, $post_tags);

                if (!empty($_FILES['file_0']['name'])) {
                  foreach ($_FILES as $file_id => $array) {
                    $attachment_id = insert_attachment($file_id,$post_id,true);
            $success = __('This post is awaiting approval by the moderators', 'frontendprofile');



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.