Currently, if you want to disable the Registration page in the website that generated with PHPMaker 9, then you have to adjust the related setting from PHPMaker application, afterwards you have to re-generate the related script files to apply the changes.
The following customization will make the ability to disable or enable the Registration page by simply adjusting the related constant value from your configuration file. In other words, we don’t have to re-generate the script files each time we want to enable/disable the Registration page.
I have added a new constant in the configuration file. If you want to disable the Registration page, then adjust the constant value to FALSE. If you want to enable it again, then simply switch it back to TRUE. The customization will also handle if users is trying to access the Registration page directly if the Registration page has been disabled (even the Register link has been hidden on the Login page). User will be automatically redirected back to the Login page if this condition is met.
In addition, the Registration page still can be accessed by user which has level of Administrator. This is very useful if you as Administrator want to register an account using the Registration page, whereas users other than Administrator level cannot access that page as they will be redirected to Login page (if they are not logged in) or to Index page (if they are logged in). This can be happened since we used IsAdmin function that you can implement it too from this article. Please note that you have to implement the customization regarding IsAdmin function in the article which I gave you the link above in order to make the result of following customization running properly.
Updated on May 30, 2012: This customization has been implemented in PHPMaker version 9.0.2, it matches to each other, and as a result, it works properly.
Updated on July 22, 2012: This customization has been implemented in PHPMaker version 9.0.3, it matches to each other, and as a result, it works properly.
Updated on September 5, 2012: This customization has been implemented in PHPMaker version 9.0.4, it matches to each other, and as a result, it works properly.
Updated on November 28, 2012: This customization has been implemented in PHPMaker version 9.1.0, it matches to each other, and as a result, it works properly.
Updated on February 9, 2013: This customization has been implemented in PHPMaker version 9.2.0, it matches to each other, and as a result, it works properly.
Updated on June 17, 2013: The customization has been handled by using MasinoLogin extension. You don’t need to implement the customization below if you use my extensions together with the original PHPMaker Template and Extension files.
[hidepost]
-
Open your \Script\ewcfg.php file, and find this code:
<!--## if (PROJ.SecRegisterPage) { ##--> define("MS_USER_REGISTRATION", TRUE, TRUE); <!--## } ##-->
if you don't find that code, please insert it before this following code (otherwise, just skip this step!):
// General
-
Open your \Script\login.php file, and find this code:
<!--## if (PROJ.SecRegisterPage) { ##--> <?php if (MS_USER_REGISTRATION) { ?> <a href="<!--##=sFnRegister##-->"><!--##@Register##--></a> <?php } ?> <!--## } ##-->
if you don't find that code, please insert it after the last line of the following code (otherwise, just skip this step!):
<!--## if (PROJ.SecForgetPwdPage) { ##--> <a href="<!--##=sFnForgotPwd##-->"><!--##@ForgotPwd##--></a> <!--## } ##-->
-
Open your \Script\phpcommon-scripts.php file, and find this code:
<!--## if (CTRL.CtrlType.toLowerCase() != "field") { if (SYSTEMFUNCTIONS.ServerScriptExist("Global","Page_Loading")) { ##--> // Global Page Loading event (in userfn*.php) Page_Loading(); <!--## } } ##-->
after that line, please insert the following code:
// Begin of modification Disable/Enable Registration Page, by Masino Sinaga, May 14, 2012 <!--## if (CTRL.CtrlID == "register") { ##--> if (MS_USER_REGISTRATION==FALSE && IsAdmin()==FALSE) { header("Location: login.php"); } <!--## } ##--> // End of modification Disable/Enable Registration Page, by Masino Sinaga, May 14, 2012
Please note that in the code above, you will find a new function named IsAdmin(). Please go to this article to add this new function by customizing the template. Make sure you don't miss this step in order to implement this current customization.
- Finally, re-generate your script files using PHPMaker as always.
[/hidepost]
Leave a Reply
You must be logged in to post a comment.