自分だったらどうするか、概要だけ書いておきます。
(product投稿タイプと仮定)
【追記】雰囲気が分かるようにしてみました。
・ログインユーザーのみアクセス可能なpage-editlist.phpを用意し、編集専用ユーザーがログインすると、そのページに強制リダイレクトするように設定。
=>省略
・編集専用ユーザーは管理画面に入ろうとしても、page-editlist.phpのページにリダイレクトするように設定。
=>省略
・page-editlist.phpでは、カスタムフィールドで事前に割り振られた担当ユーザーIDを基に、「自分が編集することができる記事リスト一覧(およびリンク)」を表示させ、リンクをクリックするとその製品ページへと飛ぶ。
※カスタムフィールド名をwriter_idとします。
PHP
1<?php
2if( !is_user_logged_in() ) header('Location: ' . get_bloginfo('url') );
3get_header();
4?>
5<div class="container">
6 <h2>あなたが担当する記事リスト</h2>
7<?php
8 $user_id = get_current_user_id();
9 $args = array(
10 'post_type' => 'product',
11 'posts_per_page' => -1,
12 'meta_query' => array(
13 'relation' => 'AND',
14 array(
15 'key' => 'writer_id',
16 'value' => $user_id,
17 'type' => 'NUMERIC',
18 'compare' => '='
19 ),
20 )
21 );
22 if( $products = get_posts( $args ) ){
23?>
24 <ul>
25<?php
26 foreach( $products as $p ){
27?>
28 <li><a href="<?php echo get_the_permalink( $p->ID );?>"><?php echo get_the_title( $p->ID );?></a></li>
29<?php
30 }
31?> </ul>
32<?php
33 }
34?>
35</div>
36<?php
37get_footer();
・single-product.phpでは、ログインユーザーIDとカスタムフィールドで事前に割り振られた担当ユーザーIDが一致している場合、編集させたいカスタムフィールドのフォームパーツを表示させ、編集・保存ができるようにしておく
single-product.php
PHP
1<?php
2
3//通常の製品紹介の下に追記
4$writer_id = get_post_meta( $post->ID, 'writer_id', true );
5$user_id = get_current_user_id();
6if( is_user_logged_in() && $user_id == $writer_id ){
7?>
8<div id="ProductInfoForm">
9 <h2>商品情報更新</h2>
10 <form name="ProductInfo" id="ProductInfo">
11 <input type="hidden" name="post_id" value="<?php echo $post->ID;?>" >
12 <?php
13 wp_nonce_field( 'UPDATEPRODUCTINFO');
14 カスタムフィールドに保存したい項目をフォームで作成
15 ?>
16 </form>
17 <script type="text/javascript">
18 jQuery(function($){
19
20 $('#ProductInfo').submit( function(e){
21 e.preventDefault();
22 var action = 'update_productinfo';
23 var $Form = $('#ProductInfo').append('<input type="hidden" name="action" value="' + action + '" >');
24 $.ajax({
25 url: '<?php echo admin_url('admin-ajax.php');?>',
26 type: 'POST',
27 data: $Form.serialize(),
28 success: function(msg){
29 alert('製品が更新されました');
30 }
31 });
32 });
33 );
34 </script>
35</div>
36<?php
37}
38?>
functions.phpに追記
PHP
1add_action( 'wp_ajax_update_productinfo', 'update_productinfo');
2function update_productinfo(){
3 $my_nonce = isset($_POST['_wpnonce']) ? $_POST['_wpnonce'] : null;
4 if( wp_verify_nonce( $my_nonce, 'UPDATEPRODUCTINFO' ) ){
5 //製品概要についてproduct_descというキーのカスタムフィールドがあったとする
6 $product_desc = filter_input( INPUT_POST, 'product_desc', FILTER_SANITIZE_STRING );
7 $post_id = filter_input( INPUT_POST, 'post_id', FILTER_SANITIZE_NUMBER_INT );
8 if( !empty( $product_desc ) ){
9 return update_post_meta( $post_id, 'product_desc', $product_desc );
10 }
11
12 }
13
14}