Hello all, I previously had an error with inputing JCaptcha on the register page. I figured out how to enable this plugin and I successful have it on the register page and it validates the captcha. (Meaning if it is wrong it throws an error code and if it is correct it registers user). The problem I am facing now is that even though it throughs an error code, it still registers the user. Do anyone have any insight on why it might be doing this? I am pasting my code below to better help the solution of this problem.

Tim Campbell
Junior, Computer Science-Ecommerce major
Winston Salem State University
tcampbell106@wssu.edu
(704) 877-2261
 

<h1>$msg.get("core.register.title")</h1>

## declare the plugin

#set($captchaPlugin = $xwiki.jcaptcha)

#if ($captchaPlugin && $reg)

##call the verifyCaptcha

#if($captchaPlugin.verifyCaptcha("edit"))

##register the user

#$xwiki.createUser(false)

#else

##display some error

#error("$msg.get('core.register.registerFailed', [$reg])")

#end

#end

#if(!$xwiki.hasAccessLevel("view","XWiki.Registration")||$xwiki.getDocument("XWiki.Registration").isNew())

#if(!$reg||$reg<0)

<p>$msg.get("core.register.welcome")</p>

#if($reg && $reg<=0)

#if($reg==-2)

#error("$msg.get('core.register.passwordMismatch')")

#elseif($reg==-3)

#error("$msg.get('core.register.userAlreadyExists')")

#elseif($reg==-4)

#error("$msg.get('core.register.invalidUsername')")

#elseif($reg==-8)

#error("$msg.get('core.register.userAlreadyExists')")

#elseif($captchaPlugin != "edit")

#error("$msg.get('core.register.registerFailed', [$reg])")

#else

#error("$msg.get('core.register.registerFailed', [$reg])")

#end

#end

#elseif($reg && $captchaPlugin.verifyCaptcha("edit"))

#set($xwname = "XWiki.${request.xwikiname}")

#info("$msg.get('core.register.successful', [$xwiki.getUserName($xwname), $request.xwikiname])")

#end

#if(!$reg||$reg<0)

<form id="register" action="verifyCaptcha" method="post">

<div>

#set($captchaPlugin = $xwiki.jcaptcha)

#if ($captchaPlugin)

##call the displayCaptcha pass the class name as "register_captcha" which should map to the css classname to render the image

##pass the name as edit

##and under http://<host>:<port>/xwiki/bin/edit/XWiki/XWikiPreferences?editor=object&

##under XWiki.XWikiPreferences[0]: XWiki.DefaultSkin select the values for Anonymous: and Registered: as image or text

<input type="hidden" name="template" value="XWiki.XWikiUserTemplate" />

<input type="hidden" name="register" value="1"/>

#set($class = $xwiki.getClass("XWiki.XWikiUsers"))

#set($obj = $class.newObject())

#set($serverobj = $class.newObject())

#set($discard = $doc.use("XWiki.XWikiUsers"))

#if($request.register_first_name)

$doc.set("first_name", $request.register_first_name)

#end

#if($request.register_last_name)

$doc.set("last_name", $request.register_last_name)

#end

<dl>

#set($prop = $class.first_name)

<dt>$msg.get("core.register.firstName")</dt>

<dd>$doc.displayEdit($prop, "register_", $obj)</dd>

#set($prop = $class.last_name)

<dt>$msg.get("core.register.lastName")</dt>

<dd>$doc.displayEdit($prop, "register_", $obj)</dd>

<dt>$msg.get("core.register.username")</dt>

<dd><input name="xwikiname" type="text" size="20" onfocus=" prepareName(document.forms.register);" /></dd>

#set($prop = $class.password)

<dt>$msg.get("core.register.password")</dt>

<dd>$doc.displayEdit($prop, "register_", $obj)</dd>

<dt>$msg.get("core.register.passwordRepeat")</dt>

<dd>$doc.displayEdit($prop, "register2_", $obj)</dd>

#set($prop = $class.email)

<dt>$msg.get("core.register.email")</dt>

<dd>$doc.displayEdit($prop, "register_", $obj)</dd>

$captchaPlugin.displayCaptcha("edit","register_captcha")

#end

</dl>

<span class="buttonwrapper"><input type="submit" value="$msg.get("core.register.submit")"/></span>

</div>

</form>

#end

#else

$xwiki.getDocument("XWiki.Registration").getTranslatedDocument().getRenderedContent()

#end

##end