We currently have a message option on our site that displays any message we add via the CMS to logged in users, but what would be the best way to offer a 'hide' option? This way if that particular user doesn't want to see the message again they could hide it? Any suggestions welcome...
Assuming that you only display one message at a time, you could add a boolean column to your Users table and set it to true when the user clicks hide, then check that column before displaying the notification.
Then, every time you make a new notification, you could reset the column to false for every user.
Assuming these are notifications/updates that users need to read, try something like this:
- When logging in, let the user know they have
N
new messages to read. - If a user goes to the messages page to read those messages, update the date with the current time in a
last_read_date
column on their user metadata.
Now, to decide what messages to show on a given login, just check the last_read_date
column against the date of each message. If the message's date is in the future relative to last_read_date
, they haven't seen that message yet.
you should add table to db that will link between users table and messages table
with fields:
userid , messageid , status
now when you have logged in user you just do
select * from messages where status='new' and userid='[userid_here]'
when user reades that message you just change the status row to something else like 'old'
this way you can show only the messages that user didnt read.