- Posts: 575
- Thank you received: 11
userpoint award after voting or comment
- ler@singmuiheng.com
-
Topic Author
- Offline
-- Joomla version -- : 3.5.1
-- PHP version -- : 5.4.45
Is there any ready solutions to award user point to customer when he comment or voting on the bought item?
Please Log in or Create an account to join the conversation.
There is no default options for that. But it could be an interesting thing.
A custom plugin could handle that, if you are not a developer you can still post a request in the commercial jobs section of this forum.
Please Log in or Create an account to join the conversation.
- ler@singmuiheng.com
-
Topic Author
- Offline
- Posts: 575
- Thank you received: 11
We are intends to do this plugin and release to alls
However, we fail to use the
onAfterVoteUpdate(&$element) API
May we know if we extend it in wrong class?
Please Log in or Create an account to join the conversation.
- ler@singmuiheng.com
-
Topic Author
- Offline
- Posts: 575
- Thank you received: 11
and modified it to create the output file, however , we confirm the event do not triggered
<?php
class plgHikashopVote_karma extends JPlugin
{
function plgHikashopVote_karma(&$subject, $config){
parent::__construct($subject, $config);
}
function onAfterVoteUpdate($element){
$fp = fopen('test.txt', 'w');
fwrite($fp, 'TRIGGERED');
fclose($fp);
}
}
Please Log in or Create an account to join the conversation.
You need a second parameter for this function, the "return_data" one.
So your code should be:
Please Log in or Create an account to join the conversation.
- ler@singmuiheng.com
-
Topic Author
- Offline
- Posts: 575
- Thank you received: 11
Xavier wrote: Hi,
You need a second parameter for this function, the "return_data" one.
So your code should be:Code:<?php defined( '_JEXEC' ) or die( 'Restricted access' ); jimport( 'joomla.plugin.plugin' ); class plgHikashopVote extends JPlugin { public function onAfterVoteUpdate(&$element, &return_data) { $fp = fopen('test.txt', 'w'); fwrite($fp, 'TRIGGERED'); fclose($fp); return true; } } ?>
tested this code however the event is still not triggering this function
do you mind to help provide a sample plugin that genarate the text file that is working?
Please Log in or Create an account to join the conversation.
Just one thing, you are using the "onAfterVoteUpdate" trigger but this trigger is called only when editing a vote or a comment.
Not when submitting one for the first time. I think that in your case you should use the trigger "onAfterVoteCreate".
Please Log in or Create an account to join the conversation.
- ler@singmuiheng.com
-
Topic Author
- Offline
- Posts: 575
- Thank you received: 11
Xavier wrote: Hi,
Just one thing, you are using the "onAfterVoteUpdate" trigger but this trigger is called only when editing a vote or a comment.
Not when submitting one for the first time. I think that in your case you should use the trigger "onAfterVoteCreate".
we did try both with this amended code
however, it was also not triggered, we did also try to submit new and editing existing vote and also posting comment
none of them trigerring this two event
also we notice $return_data parameter was not mentioned in documentation
is there any simple example we can sure that the event is triggered?
another thought is will template override cause some problem to event firing? we haven tried on other template
Please Log in or Create an account to join the conversation.
First, try on HikaShop 2.6.3
With the 2.6.2 there were some issues with the vote system so maybe you have a problem with that.
If it's still not triggering your plugin, the problem is with the plugin, either the PHP or the XML or its configuration.
In that case, please provide the full plugin and we can check what's wrong and test it on our end.
Please Log in or Create an account to join the conversation.
We have upgrade hikashop to 2.6.3 and tried the code in this url
www.hikashop.com/forum/vote/866600-hikas...msocial-s-karma.html
But it seems no function triggered after we create a vote/comment or update a vote/comment.
Can we have some help on this?
Thanks.
Please Log in or Create an account to join the conversation.
For the vote update, the trigger to use is "onAfterVoteUpdate".
Could you try with these parameters for the function instead ?
Do you have tried with a "die()" ? You have maybe not the correct rights to write a file on your server.
Please Log in or Create an account to join the conversation.
Thanks for your advise.
We tried to use "die()" after user vote/comment but still nothing was triggered
Then we try
Please Log in or Create an account to join the conversation.
And when trying to trigger "onAfterVoteCreate" is the vote/comment passed correctly ?
No error message ? Because to trigger it correctly it has to be a new vote and submitted with success.
What if you try with "onAfterVoteUpdate" ?
Please Log in or Create an account to join the conversation.
Yes the vote/comment passed successfully and no error message shown in the page.
We have tried both function but nothing happens.
Please Log in or Create an account to join the conversation.
Please provide a backend and a FTP access to your website via our contact form with a link to this topic in your message.
www.hikashop.com/support/contact-us.html
Please Log in or Create an account to join the conversation.
We have already submit the access of our testing site via the contact form:)
Thanks for your help.
Please Log in or Create an account to join the conversation.
That should be working as expected now. The system had to be a "system" plugin and not a "hikashop" one.
So the file to edit now is "plugins/system/vote_karma/vote_karma.php"
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
This is the plugin we create for this topic
Please Log in or Create an account to join the conversation.