WordPress.org

Ready to get started?Download WordPress

Forums

File Gallery
Copy attachments from another post and edit the attachment title as an editor (7 posts)

  1. jemp
    Member
    Posted 1 year ago #

    hi,

    i like the possibility to copy attachments from another post, but i would need to make the titles of the attachments editable for editors.

    best regards jemp

    http://wordpress.org/extend/plugins/file-gallery/

  2. Aesqe
    Member
    Plugin Author

    Posted 1 year ago #

    @jemp: editors should be able to edit attachment titles by default, both in media library and in File Gallery interface. Could you describe me the problem a bit more?

  3. jemp
    Member
    Posted 1 year ago #

    Thanks for your reply. I solved the problem by deleting the following code out of attachements.php

    <?php if( ! current_user_can('edit_post', $attachment->ID) ){ echo ' readonly="readonly"';} ?>

    users could only modify titles when they were able to edit posts from others users.

    best regards
    jemp

  4. Aesqe
    Member
    Plugin Author

    Posted 1 year ago #

    @jemp: are you sure you don't mean 'authors' instead of 'editors'? Because editors by default have the 'edit_posts' and 'edit_others_posts' capabilities.

    If you need to change user type capabilities, I'd rather recommend using another plugin for that (see the list here), instead of modifying plugin code directly.

  5. jemp
    Member
    Posted 1 year ago #

    I'm sorry, I meant authors. I have a german wordpress installation and there, the roles have different names. Authors cannot edit other posts and that`s ok, but I would need them to change the titles. I use wordpress in school. Pupils should be able to copy attachments and write their own titles, but they should not be able to edit other posts.
    I took a look at the proposed role manager plugins but i could not find where to change restrictions to my need.

    Thanks a lot
    Jemp

  6. Aesqe
    Member
    Plugin Author

    Posted 1 year ago #

    @jemp: a quick fix would be to hook a function to "file_gallery_edit_attachment_post_form", which outputs a javascript one-liner to make those fields editable. Try placing this somewhere in your theme's functions.php file:

    function authors_attachment_editable_fields()
    {
    	global $current_user;
    
    	foreach( $current_user->roles as $role )
    	{
    		if( $role === 'author' )
    		{
    			echo '
    			<script type="text/javascript">
    				jQuery("#fgae_post_alt, #fgae_post_title, #fgae_post_excerpt, #fgae_post_content").prop("readonly", false);
    			</script>
    			';
    		}
    	}
    }
    add_action('file_gallery_edit_attachment_post_form', 'authors_attachment_editable_fields');

    It should work :)

  7. Aesqe
    Member
    Plugin Author

    Posted 1 year ago #

    Which leads me to another issue - this means that I'm not checking user capabilities when actually updating attachment data in the database, which should be fixed right away. But that means that this code won't work in the next version of the plugin. Maybe the solution is to change the attachment owner of the copy to the user who made the copy? It actually makes sense, right?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic