plugidon't let the registration go on in this case

18 years 1 month ago #6958 by qjs2000
I also try to create a simple user plugin, I created a function which can be called before the user registration.
Yes, it works, great!

The code is like:
$_PLUGINS->registerFunction( 'onBeforeUserRegistration', 'test');

function test($user, $success) {
if($user->name == 'reserveredname')
echo ('You are not allowed to use this name');
return false;
}
return true;
}

This function will don't allow the user to use the reserverdname, it will reports the information when it happens.
But I found that the user still registered OK.

Anyone could plese help me how to not let the registeration go on in this situation?

Please Log in to join the conversation.

18 years 1 month ago #6979 by qjs2000
Maybe I didn't state my idea clearly.

I mean:
If I can stop the registeration process in the fuction, so that in some cases, the user will not be able to register?

Or if this is not the correct place I should do it? where can I?

Please Log in to join the conversation.

18 years 4 weeks ago #7278 by beat
Here an example on raising errors (there is no "return" value in this event-function/method:

[code:1]

/**
* Example registration verify user method
* Method is called before user data is stored in the database
* @param object holds the core mambo user data
* @param object holds the community builder user data
*/
function pluginExampleBeforeUserRegistration(&$user,&$cbUser) {
global $_POST, $_PLUGINS;

if ($_POST == $_POST) {
$_PLUGINS->raiseError(0);
$_PLUGINS->_setErrorMSG("Password has to be different from username!"«»);
}
return true;
}
[/code:1]

The password is not anymore in cleartext at that stage in $user. That's why it's taken from $_POST.

But all parameters can be found in $user and $cbUser.

Hope this helps,

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in to join the conversation.

18 years 3 weeks ago #7372 by qjs2000
Thanks, it works perfect. I should read the manual of Plugin more carefully.:P

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 1.775 seconds

Facebook Twitter LinkedIn