質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Q&A

解決済

1回答

299閲覧

functions.phpに設定したjsが読み込まれない

kinakomochi

総合スコア24

WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

0グッド

0クリップ

投稿2018/06/08 01:34

編集2018/06/08 01:59

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' );

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

m.ts10806

2018/06/08 02:11

起きた現象を具体的に記載してください。 >jsが適応されない状況
guest

回答1

0

ベストアンサー

これも追加

php

1add_action( 'edit_user_profile', 'profile_js' );

投稿2018/06/08 06:46

KazuhiroHatano

総合スコア7804

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問