Support

  1. yoji
  2. General
  3. Tuesday, October 13 2015, 10:56 AM
I'm in trouble to set default value.
Please give me some advice or suggestion.

I made a filed which cannot be edit by normal-users.

Visible on profile ... Yes
Visible on edit-profile ... No
Visible on registration ... No

I want to set default value to the field.
So I set a value to the Default Value field in the Options ... tab.
But it doesn't work.

Could someone help me please?
Accepted Answer
admin Accepted Answer
Admin
Hi,
checkbox and select(with multiple options enabled) fields store values into JSON format.

so values should be like ["music","movie"]

so your code become
$data['fieldAlias']='["music","movie"]';
  1. more than a month ago
  2. General
  3. # Permalink
yoji Accepted Answer
Basic
Hi, it solved all of my problems.
Thank you so much!!
  1. more than a month ago
  2. General
  3. # 1
yoji Accepted Answer
Basic
Hi thank you for your support,

It works fine with text field.
But I'm still in another trouble ...
Please help me one more time.

I could set the default value to the text field, but I couldn't set another default value to the checkbox field.
How can I set dafault value to the checkbox field?
  1. more than a month ago
  2. General
  3. # 2
admin Accepted Answer
Admin
Hi you need to write something like this if the alias of your field is "type"

defined('_JEXEC') or die;

class PlgJsnSkeleton extends JPlugin
{
public function triggerProfileUpdate($user,&$data,$changed,$isNew){
if( $isNew )
{
$data['type']='AAA';
}
}
}
  1. more than a month ago
  2. General
  3. # 3
yoji Accepted Answer
Basic
Thank you so much for your suggestion.
But I'm still in trouble...

I tried to create new plugin and activated it, then the following error message appears and my site disappears.
Could you please give me some advice?
I checked the page(44-triggers.html) but I cannot find the answer...

I'm appreciate your kind support, and hopefully, give me some more advice...




My code is here:

I made group named 'default'.
And it has a field named 'type'.
I want to set the value 'AAA' to the field.

------------------------------------- code
defined('_JEXEC') or die;

class PlgJsnSkeleton extends JPlugin
{
triggerProfileUpdate($user,&$data,$changed,$isNew){
if( $isNew ){
$data['default/type']='AAA';
}
}
}
  1. more than a month ago
  2. General
  3. # 4
admin Accepted Answer
Admin
Hi,
default value in parameter is only to fill field value in registration form. When a field is not editable then the filled value in form will be deleted.

You can do this by create a simple plugin, follow these steps:
- Download Install and enable skeleton plugin, you can find this at the end of page https://www.easy-profile.com/docs/44-triggers.html
- Open file /plugins/jsn/skeleton/skeleton.php
- remove sample functions like: triggerFieldAvatarUpdate and triggerProfileUpdate
- Create your function to add value after registration, like:
triggerProfileUpdate($user,&$data,$changed,$isNew){ 
if( $isNew ){
$data['here_field_alias']='your_default value';
}
}

This function assign a default value at your field after registration

NOTE: this code is only for example purpose, not tested and not supported.
  1. more than a month ago
  2. General
  3. # 5
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.
Sorry, the discussion is currently locked. You will not be able to post a reply at the moment.

Request Support

Support is currently Offline

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.