Temporarily give ‘manage_options’ capability

Good question! The capability checking is probably done quite early in the loading process. By looking at /wp-admin/users.php you can tell that one of the first things to happen is current_user_can( ‘list_users’ ), so that one is clearly needed or you’ll get the “Cheatin’ uh?” warning. But right before that, /wp-admin/admin.php is included, and at … Read more

Defining capabilities for custom post type

You code seems to be correct. Try the following instead. $args = array( ‘labels’ => $labels, ‘public’ => true, ‘publicly_queryable’ => true, ‘show_ui’ => true, ‘query_var’ => true, ‘rewrite’ => true, ‘hierarchical’ => false, ‘menu_position’ => null, ‘supports’ => array(‘title’), ‘capability_type’ => ‘video’ ); Update: You have to do some extra steps before making it … Read more

Allow user to Edit Posts but not Add New?

You will have to do something like this: function hide_buttons() { global $current_screen; if($current_screen->id == ‘edit-post’ && !current_user_can(‘publish_posts’)) { echo ‘<style>.add-new-h2{display: none;}</style>’; } } add_action(‘admin_head’,’hide_buttons’); See: http://erisds.co.uk/wordpress/spotlight-wordpress-admin-menu-remove-add-new-pages-or-posts-link for reference

Restrict Admin Capabilities in MultiSite

Editing super admin capabilities is a little different from editing the capabilities of every other role, because there is a slight detour in the way WP checks the current user’s capabilities. This is what you find on capabilities.php on line 864: function has_cap( $cap ) { // (…) // Multisite super admin has all caps … Read more

How to 301 private posts rather than 404?

Sorry guys, I found my answer: add_action(‘wp’,’redirect_stuffs’, 0); function redirect_stuffs(){ global $wpdb; if ($wpdb->last_result[0]->post_status == “private” && !is_admin() ): wp_redirect( home_url(), 301 ); exit(); endif; } Posts/Pages are removed from the sitemaps, but the page still shows up on the site so that it can get 301’d.

Change capability type of post type registered by plugin

@PieterGoosen is cool, and still awake like me and answering like boss. To simplify his code and make it work to this specifically without a bunch of junk on your page: /** * Pieter Goosen writes awesome code */ add_filter( ‘register_post_type_args’, ‘change_capabilities_of_the_custom_css_js_posttype’ , 10, 2 ); function change_capabilities_of_the_custom_css_js_posttype( $args, $post_type ){ // Do not filter … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)