Support

  1. rick-kasparek
  2. General
  3. Monday, August 17 2020, 11:15 PM
Is it possible to make a conditional field based on previous selections in another field?

For instance, I have added a new field group, let's call it Field Group B.

In Field Group B I place a field called "membership level" and base it on whether or not they have checked the following in field2:

Field 2: "Options" (checkbox - with multiple selections enabled) says:
1) basic membership
2) added listing: $5.00
3) added certificate $5.00

If 1) only, then "basic membership" in the field "membership level"
If 1+2, then "membership level 2" in the field "membership level"
If 1+2+3, then "membership level 3" in the field "membership level"

That way they can sign up as basic and let add the other stuff for a fee that they will pay offline.

Is that even possible?
admin Accepted Answer
Admin
Hi and sorry for late reply.

This seems possible. If you want to assign a value in the another field then you can write a simple plugin, follow these steps:
- Download, Install and Enable Skeleton Plugin (you will find it at http://docs.easy-profile.com/index.php/article/triggers)
- Open file /plugins/jsn/skeleton/skeleton.php
- remove samples functions: triggerFieldAvatarUpdate, triggerProfileUpdate
- add function like this:
public function triggerProfileUpdate($user,&$data,$changed,$isNew){ 
$field2 = (array) json_decode($data['field2alias']); // "field2alias" is the alias of Field 2
if(in_array("1", $field2)) $data['membership_level'] = 'basic membership';
if(in_array("1", $field2) && in_array("2", $field2)) $data['membership_level'] = 'membership level 2';
if(in_array("1", $field2) && in_array("2", $field2) && in_array("3", $field2)) $data['membership_level'] = 'membership level 3';
}


docs about our triggers at http://docs.easy-profile.com/index.php/article/triggers

NOTE: This code is not tested and not supported, this is only for example purpose. You need to have a minimum of PHP knowledges
  1. more than a month ago
  2. General
  3. # 1
rick-kasparek Accepted Answer
Basic
Content Protected
  1. more than a month ago
  2. General
  3. # 2
rick-kasparek Accepted Answer
Basic
Content Protected
  1. more than a month ago
  2. General
  3. # 3
admin Accepted Answer
Admin
Hi,
sorry but I have not understood well :(

Do you want to show "membership_level" field in edit profile page or in profile page? which type of field is "membership_level"?
Basically for me it's not cleat the purpose of the field "membership_level".
  1. more than a month ago
  2. General
  3. # 4
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Request Support

Support is currently Online

Support Availability

Working days: Monday to Friday. The support staff is not available on weekends; in the most of cases tickets will not be answered during that time.

Reply time: Depending on the complexity of your support issue it's usually between a few minutes and 24 hours for paid members and about one week for free members. When we expect longer delays we will notify you.

Guidelines

Before you post: read the documentation and search the forums for an answer to your question.

When you post: include Site Details if you request a support (you can use the form below the reply in Site Details tab).

Auto Solved Question: If after a week the author of the post does not reply to a request by moderator, the question will be marked as resolved.

Language: only English

Search Users

Easy Profile® is not affiliated with or endorsed by Open Source Matters or the Joomla Project. Joomla is Free Software released under the GNU/GPL License.