Support

  1. itadminMC
  2. Support
  3. Thursday, September 13 2018, 03:20 PM
Hello,
We tried to use the skeleton plugin. It seems not to work or We don't know how to make it works. The plugin is activated.
Please advice us how to.


<?php
/**
* @copyright Copyright (C) 2013 Jsn Project company. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @package Easy Profile
* website http://www.easy-profile.com
* Technical Support : Forum - http://www.easy-profile.com/support.html
*/

defined('_JEXEC') or die;

class PlgJsnSkeleton extends JPlugin
{
/*
public function triggerFieldAvatarUpdate($user,&$data,$changed,$isNew)
{
echo $user->avatar; // Old avatar value
echo $data['avatar']; // New avatar value
}
*/

public function triggerProfileUpdate($user,&$data,$changed,$isNew)
{
if(isset($data['q0q']) && !empty($data['q0q'])){
$value = $data['q0q'];
/* HERE YOU CAN ADD THE CODE TO CHECK IF THE VALUE IS VALID */
// q0q = 0 --> Private Investor
// q0q = 1 --> Investor as Company
if ($value == '0') {
$user->q8q = '1';
$user->q1q = 'Privé';
$user->save();
}
}
}
}

?>



Thanks
Regards
Accepted Answer
admin Accepted Answer
Admin
Hi,
I found 2 problems:
1) PHP empty function return TRUE also when the value is equal to '0'
2) "q1q" field is hidden by conditions, so you can not see the value in profile

You code with comments:
if(isset($data['q0q']) && !empty($data['q0q'])){
$value = $data['q0q'];
/* HERE YOU CAN ADD THE CODE TO CHECK IF THE VALUE IS VALID */
// q0q = 0 --> Private Investor
// q0q = 1 --> Investor as Company
if ($value == '0') {
// ERROR 1: this code will be never processed because the previous IF skip this code if $value is 0
// data['q8q']=1;
// ERROR 2: This field is hidden if "q0q" is equal to 0
$data['q1q'] = 'Investisseur privé';
$data['q21q'] = 'Test';
}
}
  1. more than a month ago
  2. Support
  3. # Permalink
admin Accepted Answer
Admin
Hi,
On the Error 1, could you explain us why the "if ($value == '0')" is skipped?
This IF is under another IF
if(isset($data['q0q']) && !empty($data['q0q'])){
"isset" function return true if variable exists
"!empty" (! equal to "not" ) return true if variable is not empty, but a value like "0" is interpreted as empty value from PHP

So if the value is 0 then "!empty" return false and it does not execute the code

Does this plugin work before writing values in the table?
Yes, so the value referred to error 2 should be stored in DB but it will not be visible in profile page.
  1. more than a month ago
  2. Support
  3. # 1
itadminMC Accepted Answer
Hi,
Thanks for advice.
OK for the second Error 2. For this one, we would like in fact to force the value even if this is a hidden field.
On the Error 1, could you explain us why the "if ($value == '0')" is skipped? This value is normally has '0' as a value.
Does this plugin work before writing values in the table?
Bertrand
  1. more than a month ago
  2. Support
  3. # 2
itadminMC Accepted Answer
Content Protected
  1. more than a month ago
  2. Support
  3. # 3
admin Accepted Answer
Admin
Hi,
try with this:
$data['q8q'] = '1';
$data['q1q'] = 'Privé';
  1. more than a month ago
  2. Support
  3. # 4
itadminMC Accepted Answer
Hi,

We tried this but it does not work.

Thanks
Regards
Bertrand
  1. more than a month ago
  2. Support
  3. # 5
admin Accepted Answer
Admin
Hi,
try to:
1) remove function "triggerFieldAvatarUpdate", this is only an example function

2) replace this code
$user->q8q = '1';
$user->q1q = 'Privé';
$user->save();
with this
$data['q8q'] = 1;
$data['q1q'] = 'Privé';
  1. more than a month ago
  2. Support
  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 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.