functions.phpで下記コードを設定し、ユーザーの表示内容を変更しました。
しかし、管理者が他ユーザーのプロフィールに行くと下記jsが適応されない状況です。
新規追加や他ユーザー編集時にも項目の非表示を適応させるには。アクションフックを変える方がいいのでしょうか?
よろしくお願いします。
function profile_js() { if (current_user_can( 'administrator')) { ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2').text("会員様情報"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2 + .form-table .user-first-name-wrap > th').text("担当者名"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2 + .form-table .user-last-name-wrap').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2 + .form-table .user-nickname-wrap > th').text("企業名"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2 + .form-table .user-display-name-wrap > th').text("サイト表示名"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2 + .form-table + h2').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2 + .form-table + h2 + .form-table + h2').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2 + .form-table + h2 + .form-table + h2 + .form-table').css("display","none"); }); </script> <?php }else{ ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('.wp-heading-inline').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2 + .form-table').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2 + .form-table + h2').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2 + .form-table + h2 + .form-table').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2 + .form-table + h2 + .form-table + h2').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2 + .form-table + h2 + .form-table + h2 + .form-table').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2 + .form-table + h2 + .form-table + h2 + .form-table + h2').css("display","none"); jQuery('#your-profile input[type="hidden"] + input[type="hidden"] + p + h2 + .form-table + h2 + .form-table + h2 + .form-table + h2 + .form-table + h2 + .form-table').css("display","none"); }); </script> <?php } } //アクションフックshow_user_profileにこのスクリプトを組み込む add_action( 'show_user_profile', 'profile_js' );
回答1件
あなたの回答
tips
プレビュー