Advertisement:

Author Topic: [TIP/TRICK] Redirect To Announcement On Login  (Read 39902 times)

Offline [SiNaN]

  • SMF Super Hero
  • *******
  • Posts: 11,520
  • Young and Foolish
    • SimplePortal
[TIP/TRICK] Redirect To Announcement On Login
« 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:

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

Replace:

Code: [Select]
// 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 | My Anime List | SimplePortal | Samanyolu Fanları

Offline LOADING...

  • Jr. Member
  • **
  • Posts: 305
  • Gender: Male
  • Everyday is a New Learning Day
    • http://wwww.facebook.com/ADMobOH on Facebook
    • @ADMobz on Twitter
    • ADMob Creative Marketing
Re: [TIP/TRICK] Redirect To Announcement On Login
« Reply #1 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

Offline [SiNaN]

  • SMF Super Hero
  • *******
  • Posts: 11,520
  • Young and Foolish
    • SimplePortal
Re: [TIP/TRICK] Redirect To Announcement On Login
« Reply #2 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. ;)
Former SMF Core Developer | My Mods | My Anime List | SimplePortal | Samanyolu Fanları

Offline LOADING...

  • Jr. Member
  • **
  • Posts: 305
  • Gender: Male
  • Everyday is a New Learning Day
    • http://wwww.facebook.com/ADMobOH on Facebook
    • @ADMobz on Twitter
    • ADMob Creative Marketing
Re: [TIP/TRICK] Redirect To Announcement On Login
« Reply #3 on: August 25, 2008, 11:10:11 AM »
Thank you so much!

Offline DonGiovanni

  • Sr. Member
  • ****
  • Posts: 707
  • Gender: Male
    • I need to play
Re: [TIP/TRICK] Redirect To Announcement On Login
« Reply #4 on: August 31, 2008, 11:06:30 AM »

Offline I AM Legend

  • Jr. Member
  • **
  • Posts: 182
  • Gender: Male
    • Express Forums
Re: [TIP/TRICK] Redirect To Announcement On Login
« Reply #5 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.

Offline [SiNaN]

  • SMF Super Hero
  • *******
  • Posts: 11,520
  • Young and Foolish
    • SimplePortal
Re: [TIP/TRICK] Redirect To Announcement On Login
« Reply #6 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.
Former SMF Core Developer | My Mods | My Anime List | SimplePortal | Samanyolu Fanları

Offline I AM Legend

  • Jr. Member
  • **
  • Posts: 182
  • Gender: Male
    • Express Forums
Re: [TIP/TRICK] Redirect To Announcement On Login
« Reply #7 on: October 01, 2008, 06:46:26 PM »
Awesome Ty for the help and assistance as always

Offline LOADING...

  • Jr. Member
  • **
  • Posts: 305
  • Gender: Male
  • Everyday is a New Learning Day
    • http://wwww.facebook.com/ADMobOH on Facebook
    • @ADMobz on Twitter
    • ADMob Creative Marketing
Re: [TIP/TRICK] Redirect To Announcement On Login
« Reply #8 on: October 16, 2008, 05:23:16 AM »
Thank you  ;)

Offline ahrasis

  • Language Moderator
  • SMF Hero
  • *
  • Posts: 4,663
  • Gender: Male
  • Will be very busy again soon...
    • ahmad.rasyid.ismail on Facebook
    • ahrasis on GitHub
    • @ahrasis on Twitter
    • ahrasis
Re: [TIP/TRICK] Redirect To Announcement On Login
« Reply #9 on: December 09, 2009, 04:59:41 PM »
Any update for smf 2.0 rc2?

Offline John12339

  • Semi-Newbie
  • *
  • Posts: 18
Re: [TIP/TRICK] Redirect To Announcement On Login
« Reply #10 on: July 30, 2010, 06:38:49 AM »
Will it from on SMF 2.0 RC3?

Offline Kcmartz

  • SMF Hero
  • ******
  • Posts: 4,296
Re: [TIP/TRICK] Redirect To Announcement On Login
« Reply #11 on: August 04, 2010, 09:49:44 PM »

Offline DoctorMalboro

  • SMF Hero
  • ******
  • Posts: 9,089
  • Gender: Male
  • うまいいいいいい!!!!!
    • @DoctorMalboro on Twitter
    • Personal website
Re: [TIP/TRICK] Redirect To Announcement On Login
« Reply #12 on: August 04, 2010, 11:00:41 PM »
Try changing this:

Code: [Select]
// 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:
Code: [Select]
// 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...

Offline MsAdvantageous

  • Semi-Newbie
  • *
  • Posts: 12
  • down the rabbit hole & into my heart we go.. ♥
Re: [TIP/TRICK] Redirect To Announcement On Login
« Reply #13 on: December 08, 2010, 06:48:43 PM »
can't wait for this to work on 2.0 RC3 and 4 :)

Offline CrocWeb

  • Semi-Newbie
  • *
  • Posts: 32
    • CrocWeb
Re: [TIP/TRICK] Redirect To Announcement On Login
« Reply #14 on: February 15, 2011, 02:02:13 AM »
Nice, thank you.
CrocWeb | LiteSpeed Powered cPanel Shared & Reseller Hosting Solutions
24/7 Technical Support - 60 Day Money Back Guarantee - 99.99% Uptime Guarantee
www.crocweb.com - In Business since 2009!

Offline Joshua Dickerson

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,668
  • Gender: Male
    • joshuaadickerson on LinkedIn
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?