Cant generate codes?

Hi there. Trying to use the Registration Codes module with XOOPS 2.0.17 and although the installation was successful and I believe I have everything set up correctly, the actual process of creating a code does not seem to work - after I fill out the form to create a code it returns me to the same form, and says 'There are no currently valid codes.', which there aren't - the table is empty.

I'm not really a coder, but I did notice that the insert statement listed in debug seemed to not match the table order in the database, that is to say that $instant and $redirect are transposed in the insert statement from the order they ought to be in the database. I don't know if this is significant, but in any case, changing it doesn't seem to be the answer!

Ignoring notices, I get the following warnings in debug. Again, not sure if they're significant.

On entering form initially:

Warning: in_array() [function.in-array]: Wrong datatype for second argument in file /modules/reg_codes/index.php line 220

Warning: array_reverse() [function.array-reverse]: The argument should be an array in file /modules/reg_codes/index.php line 281

Warning: Invalid argument supplied for foreach() in file /modules/reg_codes/index.php line 282

And on submitting the form to create a code:

Warning: in_array() [function.in-array]: Wrong datatype for second argument in file /modules/reg_codes/index.php line 220

...which seems to refer to initially getting group permissions, so I guess is potentially significant, though as I say, I'm no coder!

Any help or insights would be much appreciated.

Comments

RE: Cant generate codes?

Sorry for the delay in replying.

I think what is happening here is that a newer version of PHP is being more strict about some old and sloppy PHP code in the registration codes module, and the result is deleting your codes as soon as they are created. Are you using PHP 5.1 or 5.2?

If you can confirm that, then we'll dig into the affected lines and see if there's a solution with this in mind.

Thanks,

--Julian

Re: Cant generate codes?

I m facing the same problem and m using php 5.2.3. This is my localserver setup using xampp.
Xoops version 2.0.18.1
core patch files used 2.0.16 from reg codes module folder

Re: Cant generate codes?

I installed the reg codes module on my web server too, but still the same problem. Php version 4.4.7 on my webserver
Xoops version 2.0.18.1

Re: Cant generate codes?

Hello, sorry to hear you're having this trouble. There is some debug code in the index.php file for the reg codes module, and if you turn on a couple lines, it should help figure out where the problem lies.

Look around line 266 and you'll see a line that looks like this:

//print "<br>$today<br>$expiries[$i]";

And a bit lower down:

//print "<br>$maxuses[$i]<br>$curuses[$i]";

Uncomment those lines (which means, remove the // at the beginning). Save the file, upload it to your server, and try to create a code.

My guess is, you'll see two days printed out ($today and $expires[$i]). That would confirm that your system believes that the current date and the expiry date are different (expiry time, the second listed, is less than the current date).

This chunk of code checks to see if a code has expired or has reached its max number of uses. If either situation is true, the code is deleted, and so if one of those conditions is happening as soon as the code is created, it will be deleted on that page load.

Having looked at this in more detail now, I am not sure why different versions of PHP would react differently to this code. It does not do anything that I know of off the top of my head that are red flags for later versions.

Anyway, if you can uncomment that code and try to make a reg code, and see what happens, that would be helpful.

Thanks, let us know how it goes.

--Julian

Re: Cant generate codes?

I did as mentioned i.e uncomment the specified lines. Now when i try to generate codes the following line appears at the botoom of the page

Currently Valid Codes

Code:

Allows Membership in:

Valid Until:

Maximum Uses:
Current Uses:

Instant account creation:

Approval by these groups:

There are no currently valid codes.

2008-02-25
2070-12-31

Re: Cant generate codes?

Well i just used a different date i.e 2018-12-31 and it works now.
Thanks for the help.

Now on the registration page one needs to specify a code which in my case is

student for students
teacher for teachers

How to specify these codes on the registration page. i.e how should i tell ppl what codes to use for registration to the specific group.

Re: Cant generate codes?

Interesting, 2070 is probably out of range for one of the functions that is doing the date checking.

It is up to you to distribute the codes in some way that is appropriate, either through e-mail, or telling them to the right people, or writing them on a blackboard in a presentation, or whatever.

When people type in a valid code as part of the account creation process, their account will be automatically made a member of the groups associated with that code. If you specified any approval groups for the code, then someone from one of those groups will need to approve the account before the user can actually log in.

You can also create links directly to the account creation page with the code in the URL, ie:

http://www.yoursite.com/register.php?code=teachers

So you could change the "create a new account" links in your site, wherever they appear, to have "?code=teachers" on the end, for instance. In that case, we would recommend having an approval group for the code so you don't just let anyone into your site!

Of course, you don't have to change the links in your site, maybe if you're sending e-mail, instead of writing out the code and asking people to type it in, you could just put a link like the one above into the body of your e-mail message, so people just click and register.

There are a lot of possibilities.

Does that clarify things for you?

--Julian

Re: Cant generate codes?

Well thanks a lot, its a great module, without which i would have got badly stuck.
Ok i got your point about the registration process but what i want here is that on the registration page where the codes are to be entered, below it there is a line saying

If you do not have a registration code, you can click here to register for a basic account.

I wish to replace this line with something like

If you are a student, write student as your code and press submit.
If you are a teacher, write teacher as your code and press submit.

Would like to know your opinion about it and also how to do it?

Re: Cant generate codes?

Well thanks a lot, its a great module, without which i would have got badly stuck.
Ok i got your point about the registration process but what i want here is that on the registration page where the codes are to be entered, below it there is a line saying

If you do not have a registration code, you can click here to register for a basic account.

I wish to replace this line with something like

If you are a student, write student as your code and press submit.
If you are a teacher, write teacher as your code and press submit.

Would like to know your opinion about it and also how to do it?

Re: Cant generate codes?

Sure, if you want to alter the way that page looks, you can do it in the register.php file. Where it says print $codeform->render(); you can print other stuff above or below. That happens twice in the file, so you would need to modify both locations.

However, you could modify all the entry points to the register.php file, ie: wherever there are links in your site, you could change them from links to register.php, into two links, one for teachers and one for students. ie:

If you are a teacher, click here to register
If you are a student, click here to register

And then the "click here to register" part would be a link to register.php but it would include the code in the URL like this:

register.php?code=teacher
register.php?code=student

If you do that, they will bypass the screen where they type in the code, so it is easier for them.

If you do this, then you should make sure the codes have an approval group attached to them. You probably don't want just anyone signing up for these accounts. Without approval groups on these codes, anyone on the internet could click those links and automatically get an account on your website -- there is no confirmation step required with reg codes by default...the assumption is that the codes are distributed in a secret way. If you do what I've suggested above, your codes are publicaly known, so you should approve all accounts in your website before people are allowed to login.

Before you go live with this process, do some test runs to make sure the whole account creation process is the way you want it.

Good luck,

--Julian