1. rjdiepeveen
  2. General
  3. Thursday, April 24 2014, 11:26 PM
My site will have Guest, Registered, and Customer users. My questions pertain to profile updates related to the Registered -> Customer transition. Besides changing the user group, I also must update several additional profile fields, some with user input and others with system data.

What data structures are involved? How much code are we talking about?

This is 1.2.5 Pro and SP Paypal extensions
admin Accepted Answer
Admin
Hi,
if you have PHP knowledge is simple. Try to read this article https://www.easy-profile.com/docs/44-triggers.html

You can download our skeleton plugin and customize.

if you want change data or insert custom code you can write something like this:
triggerProfileUpdate($user,$data,$changed,$isNew){ 

if(!$isNew && in_array('alias_of_field1',$changed) && $data['alias_of_field1']=='custom_value_to_check')
{

// Example: change some value
$data['alias_of_field2']='something_to_assign';

// ----- Other Code -----

}

}
  1. more than a month ago
  2. General
  3. # 1
Mafketel Accepted Answer
Hi,

I would like to be able to put users in differennt groups (free, vip, super vip,...). According to this groups they will have different fields and functions.
I have a php-api for a dutch payment provider and i would like to let users pay for a user group (vip status). So after payment they automatically get vip status for the period they paid for.
Is it possible for me to create myself and can you give some directions?

Thnaks in advance
  1. more than a month ago
  2. General
  3. # 2
admin Accepted Answer
Admin
@Maf Ketel

Hi,
yes, but are only two things:
- To set avaibility of field only for some usergroups you must create Access Level (Administration->Users->Access Level), and set for fields or fieldgroups the access level parameter
- To insert user in usergroup(vip status) you can write something to add record to table #__user_usergroup_map in DB, or you may use a membership component.
  1. more than a month ago
  2. General
  3. # 3
Mafketel Accepted Answer
Hi,

Do you have any experience with membership pro for this kind of functionality?

Also, maybe akeeba subscriptions can be used?

It's not a problem for me to some little coding myself.
  1. more than a month ago
  2. General
  3. # 4
Mafketel Accepted Answer
What I want to do is: some users can fill 5 categories and other can fill 10 categories. But all categories have to be visible for guests to view.
I do not really get how to do that, can you give a little hint?
Thanks!
  1. more than a month ago
  2. General
  3. # 5
admin Accepted Answer
Admin
Hi,
before I reply to previous post
Do you have any experience with membership pro for this kind of functionality?
Yes, we use payplan but you can try with akeeba subscriptions (it's free, but not supported)

It's not a problem for me to some little coding myself. Easy Profile have hidden (for now,we have to write docs) API to implement plugins.
I will explain with an example for your usecase:
- Download our skeleton plugin (at https://www.easy-profile.com/docs/44-triggers.html) from our docs and install it
- Remove these functions triggerFieldAvatarUpdate, triggerProfileUpdate
- Add this code
public function renderPlugin()
{
if(JRequest::getVar('view',false)=='beforepay')
{

require_once(JPATH_SITE.'/components/com_jsn/helpers/helper.php'); // Load Helper
$user=JsnHelper::getUser(); // retrieve easyprofile user object - might be useful

// ADD THE CODE - BEFORE PAY (FROM YOUR PAYMENT METHOD API)
// YOU CAN STORE THE PAYMENT DATA IN SESSION,DB or FILE
// SET REDIRECT FOR YOUR PAYMENT TO index.php?option=com_jsn&view=afterpay

$app=JFactory::getApplication();
$app->redirect('your api link'); // Redirect to payment gateway or some confirmation page
return;

}
if(JRequest::getVar('view',false)=='afterpay')
{
require_once(JPATH_SITE.'/components/com_jsn/helpers/helper.php'); // Load Helper
$user=JsnHelper::getUser(); // retrieve easyprofile user object - might be useful

// ADD THE CODE - BEFORE PAY
// CHECK PAYMENT - SEND EMAILS TO ADMIN AND CUSTOMER
// SET VARIABLE $payment_ok
if($payment_ok){
JUserHelper::addUserToGroup($user->id,usergroup_id); // add to group - replace usergroup_id with valid id
$app=JFactory::getApplication();
$app->redirect('your api link'); // Redirect to thankyou page
return;

}
else{
$app=JFactory::getApplication();
$app->redirect('your api link'); // Redirect to error page
return;
}

}
}

renderPlugin function replace Easy Profile data with what you want!

In your page add a link to Payment - link is index.php?option=com_jsn&view=beforepay

We have not tested this code, is only for example!!

Second Question
You can add some other control (where clause) on query to render categories based on usergroup or accesslevel.
You can create various accesslevel and set in categories. You can check if user can see with this function
$user=JFactory::getUser();
$userAccess=$user->getAuthorisedViewLevels();

in where clause you can add
'WHERE access IN ('.implode(',',$userAccess).')'
  1. more than a month ago
  2. General
  3. # 6
Mafketel Accepted Answer
Thanks or the info. I will get working on it and try to code the solution.
  1. more than a month ago
  2. General
  3. # 7
Mafketel Accepted Answer
Hi, I got it working. I test on usergroup for the user that is displayed to decide to show some fieldsets (or fields). I use a hardcoded array of fieldsets (or fields) for this and a hardcoded usergroup id to accomplish this.
This works really nice.
I use akeeba subs to appoint groups to users according to subscriptions.

So again thanks for your help.
  1. more than a month ago
  2. General
  3. # 8
  • 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.