Support

  1. serhioromano
  2. General
  3. Wednesday, January 20 2016, 08:32 AM
Here is the idea.

I am a developer of Emerald. It is a membership extension. I want to create checkbox field for user profile that is not visible to user. Whenever user successfully subscribe, I want to add subscription plan ID to that field.

Could you give me a code snippet how that could be done the right way through API instead of custom SQL queries?
References
  1. http://www.mintjoomla.com/joomla-components/emerald.html
admin Accepted Answer
Admin
Hi,
in multivalue fields like checkbox the values are stored into Database in JSON format, you can work with arrays by using our APIs

you can use this code:
/* Load API */
require_once(JPATH_SITE.'/components/com_jsn/helpers/helper.php');
/* Sub ID */
$sub_id=3;
/* Alias of checkbox field */
$checkboxFieldAlias='checkbox_field_alias';
/* Get User Object */
$jsnUser=JsnHelper::getUser();
/* Get Current Value of Checkbox */
$userValue=( $jsnUser->getValue( $checkboxFieldAlias ) ? $jsnUser->getValue( $checkboxFieldAlias ) : array( ) );
/* If not already added then add new value and store it */
if( !in_array( $sub_id , $userValue ) ){
array_push( $userValue , $sub_id );
$user->setValue( $checkboxFieldAlias , $userValue );
$user->save( );
}


There is a problem: this function store ID of Subscription, but this ID is not valid because is not a part of Checkbox Options.

I want to create checkbox field for user profile that is not visible to user
to create a field visible only in the backend, you need to set 'Visible in edit profile' parameter to 'No' (screenshot)

Docs: http://docs.easy-profile.com/index.php/article/jsnuser-object
Attachments (1)
  1. more than a month ago
  2. General
  3. # 1
serhioromano Accepted Answer
Pro
There is a problem: this function store ID of Subscription, but this ID is not valid because is not a part of Checkbox Options.


Then condition will be to list all IDs of the plans created in checkbox field.

Some more questions.

1. Is there `JFiled` class for me to use as type of XML field element?
2. If not What is $checkboxFieldAlias? alias field from jsn_fields DB table?
  1. more than a month ago
  2. General
  3. # 2
serhioromano Accepted Answer
Pro
Sergey Romanov wrote:

There is a problem: this function store ID of Subscription, but this ID is not valid because is not a part of Checkbox Options.


Then condition will be to list all IDs of the plans created in checkbox field.

Some more questions.

1. Is there `JFiled` class for me to use as type of XML field element?
2. If not What is $checkboxFieldAlias? alias field from jsn_fields DB table?

2. If not In jsn_fields table I see type column. But there are types that are not listed for custom fields. How do I select all checkboxes? Type have to be checkbox?
  1. more than a month ago
  2. General
  3. # 3
admin Accepted Answer
Admin
Hi,
Is there `JFiled` class for me to use as type of XML field element?

Yes, you will find all classes into /administrator/components/com_jsn/models/fields/
in this folder there is a special type called parent, you can use it to get data from DB, for example also a list of all checkbox fields with this code:
<field
name="name_of_parameter"
label="label_of_parameter"
description="desc_of_parameter"
type="parent"
level="2"
table="jsn_fields"
where="a.type LIKE 'checkboxlist'"
field="alias"
multiple="false"
>
</field>


Then condition will be to list all IDs of the plans created in checkbox field.
I think this is not a optimal approach, Easy Profile extends Joomla user management with user plugins (not replace), so registration and edit profile pages are the same of Joomla (tabs are added with Javascript).
The best way to do this is to make a user plugin that creates and controls this field. For example, your plugin called "User - Emerald Subscriptions" already works with Easy profile, because works with Joomla Plugin system.
  1. more than a month ago
  2. General
  3. # 4
admin Accepted Answer
Admin
I think that some useful integration between Emerald and Easy Profile should be:
- Subscription Tab in Profile page - we already plan to make this
- Get data from Easy Profile to autofill invoice information - this is simple, we have a triggers and need to make a plugin for this(http://docs.easy-profile.com/index.php/article/triggers), when user register/update his profile then this plugin update Emerald invoice info (VAT,address,CAP,etc). User need only to set Easy Profile source field for each Emerald invoice field.
- Emerald Action: update Easy Profile field when subscription become active/expired

Other integrations can be between com_users & Emerald, these will works with Easy Profile :)
  1. more than a month ago
  2. General
  3. # 5
serhioromano Accepted Answer
Pro
I think this is not a optimal approach, Easy Profile extends Joomla user management with user plugins (not replace), so registration and edit profile pages are the same of Joomla (tabs are added with Javascript).
The best way to do this is to make a user plugin that creates and controls this field. For example, your plugin called "User - Emerald Subscriptions" already works with Easy profile, because works with Joomla Plugin system.


This is good idea. Thank you.
  1. more than a month ago
  2. General
  3. # 6
  • 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.