Advertisement:

Redirecting to Mod Function on Login

Aloittaja wixi, marraskuu 26, 2013, 01:13:49 IP

« edellinen - seuraava »

wixi

A mod I am developing requires the user to set some options before they can use it. As such, once the mod is installed, I'd like all the users to be redirected to the 'OPTIONS' page of my mod on login (if they haven't already set the options). Can someone guide me on how to to do this?

On a side not, can you also point me to more documentation on $context. Thanks.

margarett

For $context, it is filled dynamically in each action, so the variable has different values in different places.
Bes bet is to use

echo '<pre>';
print_r($context);
echo '</pre>';

Somewhere in index.template.php.

For redirect, you can use redirectexit()
http://support.simplemachines.org/function_db/index.php?action=view_function;id=224
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

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

wixi

Redirect -
So I will need to modify the login function, check if mod-options have been set, and accordingly redirectexit to appropriate action, right?

$context -
Can we add our own data to $context; like, $context["firstrun"] = 0 ?

margarett

Redirect - yes. Not sure how what you really want to do, but something in Register.php --> Register2() function. After the registration is complete, there is already a redirect:
redirectexit('action=login2;sa=check;member=' . $memberID, $context['server']['needs_login_fix']);
Where you are automatically logged in after register.
Maybe what you really need is to change the login2() function to check where you come from and then... do things :P

As for $context, yes, you can.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

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

wixi

To clarify -
After a mod is installed by the administrator, I need all the EXISTING users to set some options before they can start using it. So I want to redirect them on their next login to an "introduction / option page" so that they are informed about the mod and can then set its options if they want to use it. I think the login function should do ... will look into it and get back.

Thanks for your help.

Arantor

What options need configuring, exactly? The fact you have users that might not want to be involved does suggest you don't *need* them to configure it immediately.
Holder of controversial views, all of which my own.


wixi

Sure, in some cases a user may not need to configure a mod to use it. But some cases where you are integrating SMF with an external web app does require the immediate attention of the user (at-least in the form of a notification).


Arantor

As with everything this goes so much easier when context is given as opposed to being very generic.
Holder of controversial views, all of which my own.


Advertisement: