0

I am working on a blog where user can submit his/her story from the UI.

What I would like to happen is if a user submit his/her story it should be visible in the dashboard and i can get the attached document from the dashboard. All i can think about getting only a notification and rest of all should be manageable from the Dashboard itself.

How can I achieve the above goal?

1
  • I have created a plugin named "WP User Frontend", you can check this out.
    – Tareq
    Commented Mar 16, 2012 at 9:05

2 Answers 2

4

Before Header:

<?php 
    $post_id = $post->ID;
    if ( isset( $_POST['html-upload'] ) && ! empty( $_FILES ) ) {
        require_once( ABSPATH . 'wp-admin/includes/admin.php' );
        $id = media_handle_upload( 'async-upload', $post_id ); //post id of Client Files page
        unset( $_FILES );
        if( is_wp_error( $id ) ) {
            $errors['upload_error'] = $id;
            $id = false;
        }

        if( $errors ) {
            echo "<p>There was an error uploading your file.</p>";
        } else {
            echo "<p>Your file has been uploaded.</p>";
        }
    }
?>

After that, add this where you want your form:

<?php if ( is_user_logged_in() ) {      ?>

    <form id="file-form" enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="POST">
        <p id="async-upload-wrap"><label for="async-upload">File Upload:</label>
        <input type="file" id="async-upload" name="async-upload"> <input type="submit" value="Upload" name="html-upload"></p>

        <p><input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id ?>" />
        <?php wp_nonce_field( 'client-file-upload' ); ?>
        <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" /></p>

        <p><input type="submit" value="Save all changes" name="save" style="display: none;"></p>
    </form>

<?php } ?>
1

Gravity Forms works well for this. You can create a form which displays on the front end of the site where visitors fill out fields. These can include just about anything you want including letting them upload images or documents. After the form is submitted it will create a draft WordPress "post" which you can then update/edit and publish.

Good luck!

2
  • what i have read Gravity Forms are paid one? Commented Feb 5, 2012 at 13:30
  • Yes, it's not free. I think it's $40 for a one-site license. Well worth it IMO. You could also try the plugin Formidable but I think that's paid too.
    – Michelle
    Commented Feb 6, 2012 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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