WordPress.org

Ready to get started?Download WordPress

Forums

Widget Logic
[resolved] How to display a widget just for one particular admin? (4 posts)

  1. SuperCougar
    Member
    Posted 2 years ago #

    Hi,

    I’d like a widget to appear only when “I” am connected as an administrator.

    There are other admins on my blog and I don’t want the widget to be displayed for them or for anybody else.

    Could you please help me? I couldn’t find the correct syntax, even after consulting the conditional tags section.

    The following code works, but for all admins not just for me:

    current_user_can('administrator')

    Thanks in advance for your help.

    http://wordpress.org/extend/plugins/widget-logic/

  2. alanft
    Member
    Plugin Author

    Posted 2 years ago #

    Looks like get_currentuserinfo() (part of pluggable.php) can help. It sets the global $current_user

    http://codex.wordpress.org/Function_Reference/get_currentuserinfo

    so you could do eg something like

    global $current_user; get_currentuserinfo(); return($current_user->ID==X);

  3. alanft
    Member
    Plugin Author

    Posted 2 years ago #

    oh, as that function is in pluggable you'll have to delay the "Logic load" option from the default to 'after the theme' I think

  4. SuperCougar
    Member
    Posted 1 year ago #

    Hi Alanft,

    Excuse me for answering so late.

    Your solution works like a charm.

    Thanks a lot.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic