$username = get_input('username'); $password = get_input('password'); $password2 = get_input('password2'); $email = get_input('email'); $name = get_input('name'); $friend_guid = (int) get_input('friend_guid', 0); $invitecode = get_input('invitecode'); $admin = get_input('admin'); if (is_array($admin)) { $admin = $admin[0]; } // check the uncaptcha fields. $code = get_input('uncaptcha_code'); $trick_field = get_input(get_plugin_setting('trick_field_name', 'uncaptcha')); $error = false; if (!$code || $code != uncaptcha_generate_code()) { $error = elgg_echo('uncaptcha:register:bad_code'); } if ($CONFIG->disable_registration) { $error = elgg_echo('registerdisabled'); } if (!empty($trick_field)) { $error = elgg_echo('uncaptcha:register:non_empty_field'); } if (!$error) { try { if (trim($password) != "" && strcmp($password, $password2) == 0 && ($guid = register_user($username, $password, $name, $email, false, $friend_guid, $invitecode))) { $hidden_entities = access_get_show_hidden_status(); access_show_hidden_entities(true); $new_user = get_entity($guid); if ($guid && $admin) {
<?php // This JS is inserted to the bottom of the registration page. // It goes through and submits appends two form elements to a new, hidden form, // and submits that form instead of the displayed one. ?> <script language="javascript" type="text/javascript"> var form = $("form"); form.append('<input type="hidden" name="uncaptcha_code" value="<?php echo uncaptcha_generate_code(); ?> " />'); form.append('<input type="text" id="<?php echo get_plugin_setting('trick_field_name', 'uncaptcha'); ?> " name="<?php echo get_plugin_setting('trick_field_name', 'uncaptcha'); ?> " />'); $('captcha').hide(); function submitForm() { inputs = $(":input"); action = form[0].attributes.action.value; method = form[0].attributes.method.value; newForm = document.createElement("form"); newForm.action = action; newForm.method = method; for (i=0; i<inputs.length; i++) {