Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Invitations no longer working. Get error: "Code is required."

I have successfuly used the Invitation registration option for few weeks. Today when im trying to send an invite i get an error: "Code is required."

I still have 5 invitaions left on my account but cant figure out why i get this error.

Comments

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    If you are the admin, you should have unlimited invitations…Look in the permission settings to see what might be wrong.

  • upgrade to vanilla 2.2.1 and see if you have problems.

    2.1 is an old version.

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • @vrijvlinder said:
    If you are the admin, you should have unlimited invitations…Look in the permission settings to see what might be wrong.

    I have same issue when inviting from regular member and from admin, thats what makes this so strage.
    Do you have any idea what permission could cause this?

    Anyone know what kind of code that may be required for the Invite feature?

  • @River said:
    upgrade to vanilla 2.2.1 and see if you have problems.

    2.1 is an old version.

    Installation is 2.2.1, i cant find any setting in Dashboard to solve this error.

  • R_JR_J Ex-Fanboy Munich Admin

    This is no permission issue. "Code is required." means, well that the field Code isn't filled although it is required. This is the code in class.invitationmodel.php:
    $FormPostValues['Code'] = $this->GetInvitationCode();
    I would assume that this function fails.

    The function looks like that:

        protected function getInvitationCode() {
            // Generate a new invitation code.
            $Code = BetterRandomString(16, 'Aa0');
    
            // Make sure the string doesn't already exist in the invitation table
            $CodeData = $this->getWhere(array('Code' => $Code));
            if ($CodeData->numRows() > 0) {
                return $this->GetInvitationCode();
            } else {
                return $Code;
            }
        }
    

    There is nothing critical in there. I wouldn't know how to solve this but using some debugging code to spit out variables throughout that code.

  • RiverRiver MVP
    edited August 2016

    @vanillauzer said:

    @River said:
    upgrade to vanilla 2.2.1 and see if you have problems.

    2.1 is an old version.

    Installation is 2.2.1, i cant find any setting in Dashboard to solve this error.

    it looks like you posted in the 2.1 category, which is incorrect, that is why I suggested upgrading. But, Since you say you have 2.2.1

    If you are not a great debugger, you might try disabling all other plugins and apps besides vanilla via dashboard and switch to default theme, then determine if you have an invitation code error with the least amount of complications from themes or add-ons.

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • edited August 2016

    @River said:

    @vanillauzer said:

    @River said:
    upgrade to vanilla 2.2.1 and see if you have problems.

    2.1 is an old version.

    Installation is 2.2.1, i cant find any setting in Dashboard to solve this error.

    it looks like you posted in the 2.1 category, which is incorrect, that is why I suggested upgrading. But, Since you say you have 2.2.1

    If you are not a great debugger, you might try disabling all other plugins and apps besides vanilla via dashboard and switch to default theme, then determine if you have an invitation code error with the least amount of complications from themes or add-ons.

    Thanks for all the suggestions and help.

    Yes, you are so right. Just realized that i should have posted this in 2.2 Help. Maybe some Mod can help me move this discussion.

    Im not a great debugger, so i have now tested disabling all plugins and running default theme and im still getting same Code error.

    Any pointers to how i would go about to try debug this function?

  • R_JR_J Ex-Fanboy Munich Admin

    Make a backup copy of /applications/dashboard/models/class.invitationmodel.php

    Start by finding the line
    $FormPostValues['Code'] = $this->GetInvitationCode(); (line 102?)

    and add following lines below it:

    $Code = var_export($FormPostValues['Code'], true);
    file_put_contents(PATH_UPLOADS.'/log.tmp', "\r\ndebug1\r\n".$Code);
    

    Afterwards invite someone (invite someone that you have already invited. That way you wouldn't waste an invitation. Restore the original file (but keep the backup).

    Look at /uploads/log.tmp: does it show a bunch of random characters? If yes, please report back!
    If no, find the following lines

        protected function getInvitationCode() {
            // Generate a new invitation code.
            $Code = BetterRandomString(16, 'Aa0');
    

    Now add this below those lines:

    file_put_contents(PATH_UPLOADS.'/log.tmp', "\r\ndebug2\r\n".$Code);
    

    Invite an already invited person, restore the original file.
    Again, please report what there is in /uploads/log.tmp

  • RiverRiver MVP
    edited August 2016

    above debugging looks like a good idea.

    Did you switch php versions?

    also check your php error log for errors and post what modules you have installed and what os you have.

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • @R_J said:
    Make a backup copy of /applications/dashboard/models/class.invitationmodel.php

    Invite an already invited person, restore the original file.
    Again, please report what there is in /uploads/log.tmp

    I have now tested to debugg following your example.

    Adding these lines will only result in empty log files.
    Log files for first line:

    debug1
    ''

    Log file for second line:

    debug2

    Not sure why the log files are empty, maybe this could be the issue?

    My host did not switch php version.
    Not sure how to proceed?

Sign In or Register to comment.