• Resolved webjustice

    (@webjustice)


    Hello and thank you for a unique plugin. I need to show a menu for only the admin of a multisite installation (Not super admin). I am using a plugin called “Menu Item Visibility Control” and obviously when I switch the admin user to a subscriber role the Menu Item Visibility plugin does not recognize the change and shows the menu anyway. Which conditional logic could I use to make this work? eq: switch_back_user OR something like this?

    Thank you kindly! Carlos

    https://wordpress.org/plugins/user-switching/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Hi Carlos.

    When you switch from an administrator to another user, for example a subscriber, there should be no reason that the Menu Item Visibility plugin does not recognise the change in user. When you switch, you literally become logged in as that user.

    Have you tested your implementation works as expected if you manually log in as a subscriber rather than switching? What logic are you using to control whether the menu item appears?

    Thread Starter webjustice

    (@webjustice)

    Hi yes you are right the Menu Item Visibility plugin does not recognize the change in user. When you switch, you literally become logged in as that user.

    That is exactly my problem. I need a way to create a conditional logic (eq: ! switch_back_user, switch_to_user, switch_off_user) or any proper one, so that even though it is a subscriber user the Menu Item Visibility plugin recognizes that it is the administrator switched to subscriber. I’ve been working this for a week with no success and lots of frustration. I hope there is a way to make this happen!

    Thank you again for your precious assistance,

    Carlos 🙂

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Ah-ha, I see what you mean.

    In that case, try the current_user_switched() function which is provided by User Switching for just this purpose. It returns false normally, but if the current user has switched into their account then it returns a WP_User object (which evaluates to true, so it can be used as a conditional).

    Thread Starter webjustice

    (@webjustice)

    Excellent!! Thanks John 🙂 You are the man!! Works Perfect!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Conditional tags with Menu Item Visibility Control AND User Switching Plugins’ is closed to new replies.