Quantcast
Channel: Topic Tag: bug | WordPress.org
Viewing all articles
Browse latest Browse all 23376

PaulMorris on "Bad preview button glitch with custom role/post type/capabilities"

$
0
0

I tried creating a completely fresh test install of WordPress, and setting up the custom role, capabilities, and post type from the functions.php file (no plugins used), to see if this would correct the problem.

It didn't. I got the same behavior with the preview button, while everything else worked as it should. This leads me to believe it may be a bug in WordPress rather than something I am doing wrong.

I hate to have to resort to this, but I think I will have to try hiding the preview button with CSS, hopefully just for those custom users. The new code I used is below.


// Register Custom Post Type
function my_custom_post_type() {
$labels = array(
'name' => 'Wiki Pages',
'singular_name' => 'Wiki Page',
'menu_name' => 'Wiki Pages',
'parent_item_colon' => 'Parent Wiki Page:',
'all_items' => 'All Wiki Pages',
'view_item' => 'View Wiki Page',
'add_new_item' => 'Add New Wiki Page',
'add_new' => 'New Wiki Page',
'edit_item' => 'Edit Wiki Page',
'update_item' => 'Update Wiki Page',
'search_items' => 'Search wiki pages',
'not_found' => 'No wiki pages found',
'not_found_in_trash' => 'No wiki pages found in Trash',
);

$rewrite = array(
'slug' => 'wiki',
'with_front' => false,
'pages' => true,
'feeds' => true,
);

$args = array(
'label' => 'wpage',
'description' => 'Wiki pages',
'labels' => $labels,
'supports' => array( 'title', 'editor', 'revisions', ),
'taxonomies' => array( 'category', 'post_tag' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 25,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capability_type' => 'wpage',
'map_meta_cap' => true,

);

register_post_type( 'wpage', $args );
}
// Hook into the 'init' action
add_action( 'init', 'my_custom_post_type', 0 );

// set up custom role and custom capabilities
if ( is_admin() && '1' == $_GET['reload_caps'] ) {

if ( get_role( 'wiki_author' ) == null) {
add_role('wiki_author', 'Wiki Author', array(
'read' => true,
));
}

$administrator = get_role('administrator');
$editor = get_role('editor');
$wiki_author = get_role('wiki_author');

$wiki_author->add_cap( 'upload_files' );

foreach ( array('publish','delete','delete_others','delete_private','delete_published','edit','edit_others','edit_private','edit_published','read_private') as $cap ) {
$administrator->add_cap( "{$cap}_wpages" );
$editor->add_cap( "{$cap}_wpages" );
$wiki_author->add_cap( "{$cap}_wpages" );
}
}


Viewing all articles
Browse latest Browse all 23376

Trending Articles