vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Custom error messages when register (https://vborg.vbsupport.ru/showthread.php?t=275399)

leoglobant 12-12-2011 11:04 PM

Custom error messages when register
 
Hello.

I was wondering if you could guide me on this.

I need to know how can I show a custom error message when the user is registering. As I need to check the user existence in other system before registering, and that system is going to provide me an error message, I need to show that error as if it was from vBulletin (wrong username, wrong email and that sort of thing)

Where should I look at?

Thanks a lot in advance.

kh99 12-12-2011 11:54 PM

For the username, you could create a plugin using hook location register_addmember_process and code something like this:

Code:

if ($vbulletin->GPC['username'] is taken)
{
    $userdata->error('usernametaken', htmlspecialchars_uni($vbulletin->GPC['username']), $vbulletin->session->vars['sessionurl']);
}


and you can probably do something similar for email or other fields.

Also, the username is checked on the registration form page via a call to ajax.php, so you could create another plugin using hook ajax_start and code similar to the section that starts with
Code:

if ($_POST['do'] == 'verifyusername')
{


leoglobant 12-13-2011 09:51 PM

Thanks kh99.

Is there a way to disable the ajax user check?

Regards.

kh99 12-13-2011 09:59 PM

Yes, edit the register template and search for vbulletin_ajax_nameverif.js. That should make it easy to find the block of code below and add the <vb:comment>...</vb:comment> tags around it:

Code:

<vb:comment>
        <script type="text/javascript" src="clientscript/vbulletin_ajax_nameverif.js?v={vb:raw vboptions.simpleversion}"></script>
        <script type="text/javascript">
        <!--
                regname_verif = new vB_AJAX_NameVerify('regname_verif', 'regusername');
        //-->
        </script>
</vb:comment>


leoglobant 12-13-2011 10:17 PM

Thanks a lot!
Regards.

--------------- Added [DATE]1323879434[/DATE] at [TIME]1323879434[/TIME] ---------------

The last one about registration :D

How can I get the password without md5 applied? I see the $vbulletin->GPC['password'] but that is with md5 like $vbulletin->GPC['password_md5'].

Thanks in advance!

kh99 12-14-2011 02:36 PM

You should be able to define DISABLE_PASSWORD_CLEARING, like:

Code:

define('DISABLE_PASSWORD_CLEARING', true);

You could try putting it in a plugin, maybe using init_start. Or you could edit register.php and put it at the top.

leoglobant 12-14-2011 06:23 PM

I define that constant but I can get the password without md5 applied neither on the login nor registration. Maybe I'm using the wrong variable to get the clean password, I use the $vbulletin->GPC['vb_login_password'] variable in login and $vbulletin->GPC['password'] on registration.

--------------- Added [DATE]1323896650[/DATE] at [TIME]1323896650[/TIME] ---------------

I found out that the:

Code:

define('DISABLE_PASSWORD_CLEARING', true);
should be in the config.php file.

Thanks a lot for your help kh99!

kh99 12-14-2011 08:23 PM

Ah, config.php - that's brilliant. I'm so used to thinking about how to do things without editing files that that never would have occurred to me.

induslady 11-12-2013 02:09 PM

Hello kh99,

I have a similar requirement where in I want to customize the phrase - "usernametaken".

1)For an already existing user name the error should be -
That username is already in use. If you are {1} and you have forgotten your password, click <a href="login.php?{2}do=lostpw">here</a>.

2)For special characters and space the error should be -
That username does not meet the administrator's standards.

Any idea how I do it? Have also raised it here -
https://vborg.vbsupport.ru/showthread.php?t=304430

Thanks in advance.


All times are GMT. The time now is 03:06 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02353 seconds
  • Memory Usage 1,730KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete