News:

SMF 2.0.19 has been released! Please update. Read more.

Main Menu

[TIP/TRICK] Redirect To Announcement On Login

Started by [SiNaN], August 23, 2008, 12:28:27 PM

Previous topic - Next topic

[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:

// 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.
Former SMF Core Developer | My Mods | SimplePortal

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. ;)
Former SMF Core Developer | My Mods | SimplePortal

LOADING...



I AM Legend

Hi.
Will this trick work on 1.1.6? and can the redirect be to any board I choose?
Thanks as always.

[SiNaN]

Yes, it will work with 1.1.6. Just change the 1453 number as the ID of the board in the codes.
Former SMF Core Developer | My Mods | SimplePortal

I AM Legend

Awesome Ty for the help and assistance as always

LOADING...


Hj Ahmad Rasyid Hj Ismail


John12339



DoctorMalboro

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...

MsAdvantageous


CrocWeb

CrocWeb [nofollow] | LiteSpeed Powered cPanel Shared & Reseller Hosting Solutions
24/7 Technical Support - 60 Day Money Back Guarantee - 99.99% Uptime Guarantee
www.crocweb.com [nofollow] - In Business since 2009!

Joshua Dickerson

Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Advertisement: