News:

Wondering if this will always be free?  See why free is better.

Main Menu

any way to use fatal_lang_error with hook?

Started by Adrek, April 27, 2016, 05:37:49 PM

Previous topic - Next topic

Adrek

Hi, I'm trying to show fatal_lang_error box on custom action if user is banned on my list (added by some other mod in separate table).
I tried to integrate_load_theme but it shows only white page with my error text, theme is not loaded in this case. Then I used integrate_pre_load but this also did not work for me :|


if(isset($_GET['action']) && $_GET['action'] == 'myaction' && isset($_GET['sa']) && $_GET['sa'] == 'mysaaction')
{
$request = $smcFunc['db_query']('', '
SELECT member_id
FROM {db_prefix}pmb
WHERE member_id = {int:member_id}',
array(
'member_id' => $context['user']['id']
)
);

$row = $smcFunc['db_fetch_assoc']($request);
$pmb_user = $row['member_id'];

if(!empty($pmb_user))
fatal_lang_error('pmb_banned', false);
}


Is there any way to use hook to do this?
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

margarett

I never tried that myself, but  fatal_lang_error should load the theme if it's not loaded already...

// Try to load a theme if we don't have one.
if (empty($context['theme_loaded']) && empty($fatal_error_called))
{
$fatal_error_called = true;
loadTheme();
}


In fact,  fatal_lang_error is (potentially) called very early in index.php so pretty much any hook should work (not pre_load though :P )
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Shambles

Try changing

'member_id' => $context['user']['id']

to

'member_id' => $context['user']['id'],

Adrek

@margarett, the problem is that $context['theme_loaded'] is set after integration hook, so my fatal error doesn't allow it to be set ot true.
But thank you for pointing me in right direction, I just added before my fatal_error  $context['theme_loaded'] = true; and it works great :)

@Shambles with single item in array there shouldn't be any problem without comma at the end.
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

Advertisement: