Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Now Available => Topic started by: [SiNaN] on August 23, 2008, 12:28:27 PM

Title: [TIP/TRICK] Redirect To Announcement On Login
Post by: [SiNaN] on August 23, 2008, 12:28:27 PM
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.
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: LOADING... on August 25, 2008, 10:54:33 AM
Wow, thank you so much,
But will this work on my forum??? I am using SMF 115
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: [SiNaN] on August 25, 2008, 10:59:29 AM
Yes, it only works on 1.1.5. Just change the $board with your announcement board ID. ;)
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: LOADING... on August 25, 2008, 11:10:11 AM
Thank you so much!
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: DonGiovanni on August 31, 2008, 11:06:30 AM
This mod is now available

http://custom.simplemachines.org/mods/index.php?mod=1364
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: I AM Legend on October 01, 2008, 06:31:14 PM
Hi.
Will this trick work on 1.1.6? and can the redirect be to any board I choose?
Thanks as always.
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: [SiNaN] on October 01, 2008, 06:43:25 PM
Yes, it will work with 1.1.6. Just change the 1453 number as the ID of the board in the codes.
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: I AM Legend on October 01, 2008, 06:46:26 PM
Awesome Ty for the help and assistance as always
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: LOADING... on October 16, 2008, 05:23:16 AM
Thank you  ;)
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: Hj Ahmad Rasyid Hj Ismail on December 09, 2009, 04:59:41 PM
Any update for smf 2.0 rc2?
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: John12339 on July 30, 2010, 06:38:49 AM
Will it from on SMF 2.0 RC3?
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: KensonPlays on August 04, 2010, 09:49:44 PM
Quote from: John12339 on July 30, 2010, 06:38:49 AM
Will it from on SMF 2.0 RC3?
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: DoctorMalboro on August 04, 2010, 11:00:41 PM
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...
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: MsAdvantageous on December 08, 2010, 06:48:43 PM
can't wait for this to work on 2.0 RC3 and 4 :)
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: CrocWeb on February 15, 2011, 02:02:13 AM
Nice, thank you.
Title: Re: [TIP/TRICK] Redirect To Announcement On Login
Post by: Joshua Dickerson on June 26, 2011, 11:58:43 AM
I added this to the wiki: http://wiki.simplemachines.org/smf/Redirect_to_announcement_on_login