Support » Plugin: File Gallery » [Plugin: File Gallery] Copy attachments from another post and edit the attachment title as an editor

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Aesqe

    (@aesqe)

    @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?

    jemp

    (@jemp)

    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

    Plugin Author Aesqe

    (@aesqe)

    @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.

    jemp

    (@jemp)

    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

    Plugin Author Aesqe

    (@aesqe)

    @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 🙂

    Plugin Author Aesqe

    (@aesqe)

    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?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: File Gallery] Copy attachments from another post and edit the attachment title as an editor’ is closed to new replies.