4

I need to display a message to only users with a specific role. The message should appear either as soon as the user logs in or if they re-open their browser after having closed it when logged in to the site.

Can someone point me in the right direction as to how to go about accomplishing this? Would it be best to use PHP's sessions, HTML5's web storage or cookies in JavaScript or PHP?

-2

You can check whether this plugin helps you to achieve your purpose or You can write your own code in your custom plugin with the following approach:

  • Check if the user is logged in.
  • Check if the current user has the any roles from the specified list of roles which you want the notice to be shown.
  • If the above conditions are true just add a Notice to the site.

You might not be needing sessions as you check whether the user is logged in an show the message. If at all you need WordPress Sessions you can use the functions defined in the class WP_Session_Tokens.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.