OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Creating Account: New Inputs

Are you responsible for making OCS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, michael, John

Forum rules
What to do if you have a technical problem with OCS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved. Please note that this FAQ is OJS-centric, but most issues are applicable to both platforms.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OCS Conference Support and Discussion subforum; if you have a development question, try the OCS Development subforum.

Creating Account: New Inputs

Postby jcurtis » Thu Jul 04, 2013 10:53 am

Howdy everyone!

I am looking to add new input fields where users create their accounts. The main fields I'm trying to add are: Address Line One, Address Line Two, City, Province, Postal Code. These are required as participants can win awards that are later mailed to them.

I have been working in the createAccount.tpl file. I've tried using JavaScript to combine the these input's then add them as the value of the Mailing Address but, after an account is created the Mailing Address field in the database is left blank.

Any suggestions?

James Curtis
jcurtis
 
Posts: 45
Joined: Wed May 29, 2013 10:19 am

Re: Creating Account: New Inputs

Postby jcurtis » Fri Jul 05, 2013 7:38 am

I was also thinking of another alternative. If there was a way to disable the TinyMCE for the mailing address only that would work well.

James Curtis
jcurtis
 
Posts: 45
Joined: Wed May 29, 2013 10:19 am

Re: Creating Account: New Inputs

Postby asmecher » Fri Jul 05, 2013 9:03 am

Hi James,

To disable TinyMCE for the mailing address field, look through plugins/generic/tinymce/TinyMCEPlugin.inc.php and remove any cases with 'mailingAddress'.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8306
Joined: Wed Aug 10, 2005 12:56 pm

Re: Creating Account: New Inputs

Postby jcurtis » Thu Jul 11, 2013 7:48 am

Hi Alec,

I removed these items and it worked perfectly.

I was making the same changes to the templates/registration/userRegistrationForm.tpl and now when a user creates their account whilst registering for a conference at the same time, the error "DB Error: Duplicate entry '9-9-695-32768' for key 'roles_pkey'" appears. The user's information is entered into the database, but from there, the registration stops, the error is displayed and the users cannot continue with the registration.

I also tried logging onto a user account that was created that was and was presented with a 404 error.

Any Ideas?

James Curtis
jcurtis
 
Posts: 45
Joined: Wed May 29, 2013 10:19 am

Re: Creating Account: New Inputs

Postby asmecher » Fri Jul 12, 2013 3:24 pm

Hi James,

Are you working with the database manually e.g. deleting user entries? UserRegistrationForm, when creating a user, first inserts the user then inserts a single role; I suspect either the process you're using or the modifications you're making are causing the error.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8306
Joined: Wed Aug 10, 2005 12:56 pm

Re: Creating Account: New Inputs

Postby jcurtis » Thu Jul 18, 2013 4:50 am

Hi Alec,

The problem seemed to debunk it's self after registering a couple of times.

The rest of this message will be the solution to this topic. I know this is a lot to read (part of the documentation I'm writing), but this solution has worked very well for me so far. If you can think of any bugs or comments let me know.

Also, if anyone would like to see some of the code I wrote up for this let me know!

User account Creation

Mailing Address
File: templates/user/createAccount.tpl

The mailing address was changed to include Address Line One, Address Line Two, City, Province, Postal Code.

Instead of adding new column’s to the database to store the information, I made use of the already existing “mailing_address” in the “users” table. To do this, I added the necessary text boxes and drop down box to gather the required information. When the form is submitted, the Javascript function called validateForm() takes effect. This function first gets the values of each address input and removes any HTML tags inside (similar to PHP’s strip_tags function). Next the address information is compiled together and inserted into the mailingAddress input. Then the address information is separately validated. The address information does not require an Address Line Two, so it can remain blank. If Address Line One or City or Province or Postal Code is left blank, or the postal code does not meet the Canadian Postal Code, false is returned and the form displays the proper form error messages. If the Address information meets the required standards, true is returned and the form continues to process.

To have the address information restored upon a false submission , the checkAddress() function was used. This function RELIES on <img src="/conferences/images/doNotRemove.png" onload="checkAddress()"> as the onload function cannot be used anywhere else on the form. First this function checks to see if the user had previously submitted the form by checking if the mailingAddress is empty or not. If the mailingAddress is not empty, the mailingAddress is broken down into it’s designated input using split("<br>").

In place of the Mailing Address from the users perspective, the users mailing address is displayed to encourage users to double check their mailing address. This was done using the addressFunction() function and the postalFunction() function. The addressFunction() gathers all the address information and displays the information in a relevant format. This function is called when any input in the address information is changed. The postalFunction() is only called when the user enters information for the postal code. If the user entered data that does not align with the Canadian Postal Code, the description of the proper format the postal code is highlighted red for a visual warning.

File: plugins/generic/tinymce/TinyMCEPlugin.inc.php
The mailingAddress was previously using the TinyMCE plugin, a web based HTML editor. Due to this causing problems when changing the value of the mailingAddress, all occurrences of “mailingAddress” were removed in this file.


Affiliation
File: templates/user/createAccount.tpl

Affiliation needed to be changed from a text area to a drop down menu that consists of the various Atlantic Universities. In addition the many options, “Other” is included, where if selected, the user is presented with a textbox to write their affiliation. This was done using the affiliationFunction() function.

When the form is submitted the affiliation information is run through the validateForm() function similar to the mailingAddress. If the drop down menu’s value is equal to “Other”, the value of affiliation will be what the user enters into the text box. Otherwise, the value of affiliation will be the item selected in the drop down menu. No validation needed to be written for affiliation as OCS already contains form validation for affiliation.

If the form is submitted incorrectly the checkAddress() function is called to repopulate the form. For affiliation, this function compares the Atlantic Universities to the information that the user entered. If the information the user entered is not within the Atlantic Universities, the hidden text box is displayed with the information the user previously entered. If the information the user entered in within the Atlantic Universities, the hidden text box remains hidden and the drop down menu displays the associated university.


Other Create Account Inputs
As many of the default inputs on the “Create Account” page have no use for the conference, they were hidden from the user using style=”display:none;”. The reason for not completely erasing the input’s was to not interrupt the way in which OCS writes the information into the database.

The following inputs were hidden using style=”display:none;”:
    Gender
    Initials
    URL
    Fax
    Signature
    Create Account as (default: reader)


“User” Edit Profile Page
File: templates/user/profile.tpl

As the users “Edit Profile” page has to mimic the “Create Account” page, the same changes that were made to this file. For more information see Mailing Address, Affiliation and Other “Create Account” Inputs.


User Registration Form
File: templates/registration/userRegistrationForm.tpl

Since the registration contains a “Create Account” form as part of the registration process, it was changed to only be accessible when the user is logged in. This was done using {if $userLoggedIn} (a function that is built into OCS) and an {else} statement at the bottom of the page. If this user is logged in, they are presented with the normal registration form. If the user is not logged in, the user is presented with a brief text and two links; the login page link and create account page link.
These two links take the user to the login page or the create account page, that is associated with the conference the user is currently trying to register for. This was done using the links($word1, $word2) function. This function uses the current relative document path and replaces the last two words in the URL (schedConf & registration) with the new words established when calling the function.

Cheers,
James Curtis
jcurtis
 
Posts: 45
Joined: Wed May 29, 2013 10:19 am


Return to OCS Technical Support

Who is online

Users browsing this forum: Bing [Bot] and 2 guests