Support

  1. DATAFull
  2. Features Request
  3. Wednesday, March 18 2020, 07:48 PM
I would like to know if it is possible to create a field to change the User permission group in K2.

Thanks in advance for your help.
admin Accepted Answer
Admin
Hi,
Easy Profile does not do this natively but it is possible by creating a simple Plugin, you can follow these steps:
- Download our skeleton plugin (you can find it at http://docs.easy-profile.com/index.php/article/triggers)
- Install it from Joomla Installer
- Enable it from Extensions->Plugins
- Open file /plugins/jsn/skeleton/skeleton.php
- Remove sample functions: "triggerFieldAvatarUpdate" and "triggerProfileUpdate"
- Add a function like this:
public function triggerProfileUpdate($user,&$data,$changed,$isNew)
{
if(isset($data['HERE_THE_ALIAS_OF_YOUR_FIELD']) && !empty($data['HERE_THE_ALIAS_OF_YOUR_FIELD'])){
$value = $data['HERE_THE_ALIAS_OF_YOUR_FIELD'];
if($value == 'opt1') {
/* HERE THE CODE TO ADD USER TO K2 GROUP, FOR EXAMPLE WITH A SQL QUERY */
}
else{
/* HERE THE CODE TO REMOVE USER FROM K2 GROUP, FOR EXAMPLE WITH A SQL QUERY */
}
}
}


IMPORTANT NOTE: This code is not tested and not supported, this is only for example purpose.
  1. more than a month ago
  2. Features Request
  3. # 1
DATAFull Accepted Answer
Pro
Thanks for the answer, but it was a little vague, after configuring the code, what is the procedure to create a select with this function? I didn't see any way to customize the selects, is there any specific field to use this skeleton?
  1. more than a month ago
  2. Features Request
  3. # 2
admin Accepted Answer
Admin
Hi,
before use this code you have to create the field, for example a field of type select with alias like "k2_group" and following options
normal|Normal
author|Author
each option need to have following syntax "value|text"

So after create the field you can customize the code with something like
public function triggerProfileUpdate($user,&$data,$changed,$isNew)
{
if(isset($data['k2_group']) && !empty($data['k2_group'])){
$value = $data['k2_group'];
if($value == 'author') {
/* HERE THE CODE TO ADD USER TO K2 GROUP, FOR EXAMPLE WITH A SQL QUERY */
}
else{
/* HERE THE CODE TO REMOVE USER FROM K2 GROUP, FOR EXAMPLE WITH A SQL QUERY */
}
}
}
  1. more than a month ago
  2. Features Request
  3. # 3
  • 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.