How to accept Terms & Conditions again

Issue

  • If you want the users to accept the Terms and Conditions one more time.

Environment

  • Liferay DXP 7.0

Resolution

In Liferay OOTB (Out Of the Box) there is no feature available to enable the "terms and condition" page second time. For enabling the "Terms and condition" page second time, AgreedToTermsOfUse column of user_ table in Database needs to be modified which is by default set to "0" and when user clicks "I agree" it converts to "1" in this column. 

Therefore, you may use the Liferay API UserLocalServiceUtil.updateAgreedToTermsOfUse(args) to update the value of AgreedToTermsOfUse column of user_ table or you may execute the following groovy script to update the value of AgreedToTermsOfUse column of user_ table.

Below is the Groovy script to update the value of AgreedToTermsOfUse to "0" for all the users. Following is the steps to execute the Groovy script:
1) Login as administrator, go to Control Panel --> Server Administrator --> Script --> Select "Groovy" 
2) Paste the following groovy script and click on Execute.

import com.liferay.portal.kernel.model.User;
import com.liferay.portal.kernel.service.UserLocalServiceUtil;

import java.util.List;

/**
 * The following code will get all of the users.
**/
List<User> Users = UserLocalServiceUtil.getUsers(-1, -1);

for(User user : Users) {
      /**
      * If you want some special users enable the Terms & Condition page again, you
      * should add conditions, eg. user.getFullName.equals("Jack Lee"), user.isActive().
      **/
      if(user.isAgreedToTermsOfUse()) {
          UserLocalServiceUtil.updateAgreedToTermsOfUse(user.getUserId(), false);
      }
}

Results 

After executing the above script, all the users would get the "terms and condition" page again.

 

Additional Information

It is always recommended to note the below steps before following the above steps :  

1) Take the backup of the database before executing the groovy script, so if anything goes wrong you may restore the database.

2) "terms.of.use.required" must be true in the portal-ext.protperties, by default it is set to true, hence, if "terms.of.use.required" is not available in portal-ext.properties, it is fine, but make sure you don't set "terms.of.use.required=false" in portal-ext.properties.

3) If you want to enable the "Terms and condition" page again for some specific user, you need to add the condition for the users you want to enable the Terms & Condition page again, you may refer commented portion in the Groovy script for the same.

4) Please test the reported behavior on your lower environment and then move the production as per your discretion.

5) This resolution requires customization and should only be implemented at the discretion of your team. Liferay Support will not be able to assist with designing or implementing customizations.

 

Was this article helpful?
2 out of 2 found this helpful