WordPressのユーザー情報カスタマイズについてお聞きしたいことがあります。
WordPressのデフォルトで設定されている、ユーザー情報の名前だったり、ニックネームといった項目名を別の物に変更したいのですが、探してみても項目の削除か追加しかありません。
項目名変更はjQueryなどでやるしか方法がないのでしょうか。
よろしくお願いします。
「:contains」とか使ってみましたが、うんともすんとも言わなかったので妥協案として下記コードにしましたが、とても綺麗とは言えない状態です。
何かいい方法ありますでしょうか。
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' );
追記
上記コードで運用していたのですが、突然「current_user_can( 'administrator')」側のスクリプトが読み込まれなくなってしまいました。
else側に該当するアカウントは問題なく動作しています。
プラグイン「Adminimize」で権限の設定をしているのですが、権限設定によって読み込まれなくなるなどあるのでしょうか。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。