ログイン時のみ見える情報を作るプラグイン「Private Content」
≪≪この記事をすべて読むには約 5 分かかります≫≫
ブログに書いた記事はそのまま誰にでも見えるのが基本だと思います。ただ、時々後で見返した時に自分が参考にしたいこともあるのではないかと思います。
ログインしたユーザー(もしくは特定のユーザー)だけが見られる部分を作るプラグイン「Private Content」を別サイトで導入しました。
Private Content
ショートコードを入れるとその部分だけ特定ユーザーにのみ見えるようになるというプラグインです。PHPをいじれば作れるという情報はあちこちにありますが、プラグインの形でないと、忘れたころにメンテナンスできなくなるのが難点だと思っています。
別のサイトに移植するときとか、壊れた時に再現するのが大変です。ブログに載せていたとしても、結構大変ですよね。function.phpに設定した項目を何年もたって覚えているのか、とか、テーマを変えた時になくなってしまって困ったとか、最近よく困っています。
そういうものを解決するには、やはり配布されているプラグインに頼るのが良いです。CSSで指定するとかそういうものと違って、ソースコードにも表示されないのでまあまあ安心できます。
使い方
有効にしたら、必要な部位にショートコードを挿入します。
[[private]] ログインユーザーにのみ見せたい情報 [[/private]](一重の【】で囲む)
が基本です。 privateの後に [[private role=administrator]]などを入れると管理者のみ見られる、などのカスタマイズができます。
administrator | Administratorsのみ |
editor | Editors and Administrators |
editor-only | Editorsのみ |
author | Authors, Editors, Administrators. |
author-only | Authorsのみ |
contributor | Contributors, Authors, Editors, Administrators. |
contributor-only | Contributorsのみ |
subscriber | Subscribers, Contributors, Authors, Editors, Administrators. |
subscriber-only | Subscribersのみ |
visitor / visitor-only | ゲストのみ見られるが、Administratorsは読める |
none | When used, it is mandatory to use also the recipient option. The hidden text is shown only to users in the recipient list. Administrators cannot read the hidden text. |
custom | When used, it is mandatory to use also the custom_role option. The hidden text is shown only to users that have a role in the custom_role list. Administrators can read the hidden text. |
custom-only | When used, it is mandatory to use also the custom_role option. The hidden text is shown only to users that have a role in the custom_role list. Administrators cannot read the hidden text. |
後半のはさらに複雑です。role以外のオプションも指定して記載する必要があります。そこまでする必要があることが、Wordpressで必要なのかは疑問ですが・・・。
ディスカッション
コメント一覧
まだ、コメントがありません