WordPress.org

Ready to get started?Download WordPress

Forums

Frontend Uploader
[resolved] Admin-side : Force File Author ? (3 posts)

  1. dapickboy
    Member
    Posted 1 year ago #

    Hi !
    When I upload a file as a visitor (i.e. not logged in), the file get no author. It's fine for me, but when I approve it through the manager, it sets my user as the author of the file.
    Could it be possible to force it to be "visitor" (for example, but maybe it's impossible for WP to set it at a non-existent user...) at upload ?
    Or maybe add some info via filters to let us know that, in our big media library, this file was uploaded via frontend uploader ?

    Anyway, the plugin works like a charm !

    http://wordpress.org/extend/plugins/frontend-uploader/

  2. Rinat Khaziev
    Member
    Plugin Author

    Posted 1 year ago #

    Howdy,

    Yes, it's totally possible with filter 'fu_after_upload'. You might want to create a dummy user, say "Visitor", set its role to Subscriber. Say, it has ID 3. After that put something like the code snippet below into your theme's functions.php.

    add_action( 'fu_after_upload', 'my_fu_after_upload' );
    function my_fu_after_upload( $attachment_ids ) {
        // do something with freshly uploaded files
        foreach ( $attachment_ids as $att_id ) {
           // Set a different author
            wp_update_post( array( 'ID' => $att_id, 'post_author' => 3 ) );
        }
        // This happens on POST request, so $_POST will also be available for you
    }

    I'm glad that you're enjoying the plugin, mind giving some stars? :)

  3. dapickboy
    Member
    Posted 1 year ago #

    Hi !

    For sure I'll give it five stars ! Though there might be some improvement or functions to come, it does a very good job and is really versatile through the hooks and filters. That's great !

    And thanks a lot for your snippet, it's just what I wanted. And I even didn't thought of creating a dummy user...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.