Customizing SMF > Now Available

[TIP/TRICK] Redirect To Announcement On Login

(1/4) > >>

[SiNaN]:
Question: How do I redirect the member on login to the last created topic in my announcement board, if he didn't read it yet?
Original Topic: -

../Sources/LogInOut.php

Find:


--- Code: --- // Just log you back out if it's in maintenance mode and you AREN'T an admin.
if (empty($maintenance) || allowedTo('admin_forum'))
--- End code ---

Replace:


--- Code: --- // The board to look for.
$board = 1453;

// Get the last topic.
$request = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}topics
WHERE ID_BOARD = $board
ORDER BY ID_TOPIC DESC
LIMIT 1", __FILE__, __LINE__);
list ($topic) = mysql_fetch_row($request);
mysql_free_result($request);

// Check if he read that topic.
$request = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}log_topics
WHERE ID_TOPIC = $topic
AND ID_MEMBER = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
list ($read) = mysql_fetch_row($request);
mysql_free_result($request);

// Just log you back out if it's in maintenance mode and you AREN'T an admin.
if((empty($maintenance) || allowedTo('admin_forum')) && empty($read))
redirectexit('topic=' . $topic . '.0');
elseif ((empty($maintenance) || allowedTo('admin_forum')) && !empty($read))
--- End code ---

1453 should be change as the ID of the announcement board.

LOADING...:
Wow, thank you so much,
But will this work on my forum??? I am using SMF 115

[SiNaN]:
Yes, it only works on 1.1.5. Just change the $board with your announcement board ID. ;)

LOADING...:
Thank you so much!

DonGiovanni:
This mod is now available

http://custom.simplemachines.org/mods/index.php?mod=1364

Navigation

[0] Message Index

[#] Next page

Go to full version