Tag Info

Hot answers tagged

3

admin_init runs on admin pages, not the front end. The equivalent front end action, init, is too early to check is_page. A safe action for redirection is template_redirect: function xyz() { if( is_page( 172 ) && ! current_user_can('update_core') ) { wp_redirect( home_url() ); exit; } } add_action( ...


2

You can use a filter to pre_get_posts so that only your posts are listed. Something like this: function my_posts_only( $query ) { global $pagenow; if ( 'edit.php' != $pagenow || ! $query->is_admin ) return $query; if ( ! current_user_can( 'manage_options' ) ) { global $user_ID; $query->set( 'author', $user_ID ); ...


2

You could create a simple page template with just five lines of code: /* Template Name: Protected Page */ if ( ! is_user_logged_in() ) auth_redirect(); else require_once './page.php'; Then select that template for the page you want to protect. auth_redirect() will send the user to the login page and back to the original URL after they are logged ...


1

So, thanks to kaiser, I was able to figure it out. I had to do two things to make this work. First, I noticed that disabling the WP User Avatar plugin was causing the errors to disappear. I looked and realized that a setting was checked "allow subscribers and contributors to edit their avatars." Unchecking it and saving it for each site made the errors ...


1

Yes this is possible. Add the following to either your plugin code or the theme's functions.php file: function mypo_parse_query_useronly( $wp_query ) { if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) { if ( !current_user_can( 'update_core' ) ) { global $current_user; $wp_query->set( ...


1

The ability to set comment status is tied to the "edit_comment" capability, which is a meta-capability in WordPress. It maps to the "edit_post" capability, which is another meta-capability that varies depending on whether a post is published or not. In the end, if a post is published, then edit_comment ends up mapping to "edit_published_posts" for the ...



Only top voted, non community-wiki answers of a minimum length are eligible