実現したいことは、WP管理画面で、投稿&カスタム投稿で、ユーザーが投稿した記事以外を非表示にしたいです。
編集者権限が複数いる仕様になります。
投稿は以下のコードで出来ましたが、カスタム投稿はどのように記述したらよろしいのでしょうか。
ご教授いただけますでしょうか。
//投稿閲覧制限 if (!current_user_can('level_10')) { function exclude_other_posts( $wp_query ) { if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) { $post_type = get_post_type_object( $_REQUEST['post_type'] ); $cap_type = $post_type->cap->edit_other_posts; } else { $cap_type = 'edit_others_posts'; } if ( is_admin() && $wp_query->is_main_query() && ! $wp_query->get( 'author' ) && ! current_user_can( $cap_type ) ) { $user = wp_get_current_user(); $wp_query->set( 'author', $user->ID ); } } add_action( 'pre_get_posts', 'exclude_other_posts' ); }
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/09/07 05:22