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:
// Just log you back out if it's in maintenance mode and you AREN'T an admin.
if (empty($maintenance) || allowedTo('admin_forum'))
Replace:
// 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))
1453 should be change as the ID of the announcement board.
Wow, thank you so much,
But will this work on my forum??? I am using SMF 115
Yes, it only works on 1.1.5. Just change the $board with your announcement board ID. ;)
Thank you so much!
This mod is now available
http://custom.simplemachines.org/mods/index.php?mod=1364
Hi.
Will this trick work on 1.1.6? and can the redirect be to any board I choose?
Thanks as always.
Yes, it will work with 1.1.6. Just change the 1453 number as the ID of the board in the codes.
Awesome Ty for the help and assistance as always
Thank you ;)
Any update for smf 2.0 rc2?
Will it from on SMF 2.0 RC3?
Try changing this:
// 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);
with this:
// The board to look for.
$board = 1453;
global $modSettings;
// Get the last topic
$sql = $smcFunc['db_query']('', '
SELECT ID_TOPIC
FROM {$db_prefix}topics
WHERE ID_BOARD = $board
ORDER BY ID_TOPIC DESC
LIMIT 1",__FILE__, __LINE__);
$topic = $smcFunc['db_fetch_assoc']($sql);
$smcFunc['db_free_result']($sql);
);
and tomorrow morning i'll check the other one if i can...
can't wait for this to work on 2.0 RC3 and 4 :)
Nice, thank you.
I added this to the wiki: http://wiki.simplemachines.org/smf/Redirect_to_announcement_on_login