WordPress.org

Ready to get started?Download WordPress

Ideas

Extend 'attachment' type with custom post type 'capabilities' field

  1. aoberoi
    Member

    12345

    currently if i register a custom post type, i have not been able to set 'capabilities' to 'attachment' and get an interface in the Admin area. i would like to do this so i can "extend" the type of attachment and make it a specific item that a client can work with. I like the builtin functionality of having attachments with parent posts and all that and i do not want to have to duplicate it on my own.

    thanks!

    Posted: 3 years ago #
  2. djbokka
    Member

    Any luck on this issue? I have the same problem but can't seem to find ANY information on it.

    Posted: 3 years ago #
  3. djbokka
    Member

    I may have found something. It looks as though the attachment capabilities are not part of the admin permissions by default.

    I installed the "Members" plugin:
    http://justintadlock.com/archives/2009/09/17/members-wordpress-plugin

    Then added the attachment capabilities per the docs:
    http://codex.wordpress.org/Function_Reference/register_post_type

    Specifically:
    -edit_attachment
    -edit_attachments
    -edit_others_attachments
    -publish_attachments
    -read_attachments
    -read_private_attachments
    -delete_attachments

    My attachments post type then shows up on the UI and is accessible.

    It's not doing everything I want yet but it's progress.

    Posted: 3 years ago #
  4. Baden
    Member

    Note to others:
    Installing Members Plugin is the right first step, but adding the Custom Capabilities:

    -edit_attachment
    -edit_attachments
    -edit_others_attachments
    -publish_attachments
    -read_attachments
    -read_private_attachments
    -delete_attachments

    and/or

    edit_attachment
    edit_attachments
    edit_others_attachments
    publish_attachments
    read_attachments
    read_private_attachments
    delete_attachments

    does not seem to affect the media library capabilities whatsoever. So far this only seems to be controlled by the edit_post capabilities.

    Posted: 1 year ago #
  5. Baden
    Member

    Update:
    Add the following to your theme's function.php:

    //fix media permissions
    function fix_media_permissions() {
        global $wp_post_types;
        $wp_post_types['attachment']->cap->edit_posts = 'edit_attachments';
        $wp_post_types['attachment']->cap->delete_posts = 'delete_attachments';
    }
    add_action( 'admin_init',  'fix_media_permissions' );

    http://core.trac.wordpress.org/ticket/19834#comment:11

    Posted: 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    7 Votes
  • Status

    This is plugin territory