Connection type added regarding usergroup

3 years 3 months ago #321618 by ericmuc
Hi,

In the config I added connection types with the name of special usergroups, for example SPGROUP.

If a user get a connection request, he can set the connection type at manage connections.

Here I want to have an auto action: the connection type SPGROUP shall be set automatically to the usergroup of the connected profile (SPGROUP).

By this the user can send pms or give privacy rights to only connected usergroups.

I took a look at the auto actions with type connections, but here I can only set new connections with triggers. So is there a way to achieve my idea?

Thanks, best regards
Eric

Please Log in to join the conversation.

3 years 3 months ago #321628 by krileon
Replied by krileon on topic Connection type added regarding usergroup
There isn't a trigger for when 1 specific connection has its type changed. There's only onBeforeSaveConnectionsRequest which is fired before the connections are looped through and their type is saved. The user ids of the connections being saved are in var1 as an array. What you could try doing is the below to have CB Auto Actions loop through them.

Global
Triggers: onBeforeSaveConnectionsRequest
Type: Usergroup
User: Manually
User Variable: Variable 1
Conditions
Field: Value
Custom Value: [post_[action_user]connectiontype]
Operator: Does Contain
Delimiter: |*|
Value: SPGROUP
Action
Mode: Add Usergroups
Groups: SELECT_GROUPS_HERE

The connection type the connection is being set to is an array of connection types since multiple are allowed. It's also specific to a user id. The [action_user] substitution happens by force using str_replace before all other substitutions so it can be used in the middle of another substitution safely like shown above. I have also tested the above as working so it should for sure cover your usage.

If you need to remove the usergroup you need to make a copy of the above auto action. Change its condition to Does Not Contain then use a Mode of Remove Usergroups.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

3 years 3 months ago #321688 by ericmuc
Replied by ericmuc on topic Connection type added regarding usergroup
Hi,
Thanks, I understand and thank you for this example. Is your example for adding a usergroup by setting a connection type? Good to know this.

But I need following auto action:
- the joomla system has the usergroup SPGROUP
- the connection type SPGROUP is available (same name)
- the user1 who requested the connection with user2 has the usergroup SPGROUP
- by accepting the request by user2 the connection type shall be set to SPGROUP automatically

Is that possible? Excuse me to write my need not clear enough in first post.
Thanks, best regards
Eric

Please Log in to join the conversation.

3 years 3 months ago #321694 by krileon
Replied by krileon on topic Connection type added regarding usergroup

Is your example for adding a usergroup by setting a connection type?

Yes, with the above auto action when you add a connection type of SPGROUP to the user they are given the usergroup SELECT_GROUPS_HERE.

But I need following auto action:
- the joomla system has the usergroup SPGROUP
- the connection type SPGROUP is available (same name)
- the user1 who requested the connection with user2 has the usergroup SPGROUP
- by accepting the request by user2 the connection type shall be set to SPGROUP automatically

Ok, my above suggestion won't do that. Sorry, misunderstood what you were asking.

Is that possible? Excuse me to write my need not clear enough in first post.

Yes, you can use the trigger onAfterAcceptConnection to add behavior on accepting a connection request. [var1] is user1 user id and [var2] is user2 user id using your example above. You can use that information to modify the connection in the database directly. The below should work.

Global
Triggers: onAfterAcceptConnection
Type: Query
User: Manually
User Variable: Variable 2
Access: SPGROUP
Action
Query:
UPDATE `#__comprofiler_members` SET `type` = 'SPGROUP' WHERE `referenceid` = '[var1]' AND `memberid` = '[var2]'

Notice we're pointing the user of the action at the user2 user id. We're doing this so we can use the built in ACL functionality to make sure they've the SPGROUP usergroup. If it adds the connection type to the wrong connection direction switch var1 and var2 in the query.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

3 years 3 months ago #321708 by ericmuc
Replied by ericmuc on topic Connection type added regarding usergroup
Hi,
Great, many thanks for this good help! Question: is there a documentation available about using the variables? I don't understand how to use them.

I got it work now for my three different connection types / usergroups.

Due to this auto action the connection type is set only for the connection of user 1 to user2. User2 was requested and by accepting the request, the user1 connection type is set to the usergroup of user2. That is right.

But how can I manage it, that user2 gets also the connection type of user1 to his connection with him? User1 can also belong to different usergroups.

Thanks, best regards
Eric

Please Log in to join the conversation.

3 years 3 months ago #321733 by krileon
Replied by krileon on topic Connection type added regarding usergroup

is there a documentation available about using the variables? I don't understand how to use them.

Yes, the variables available to triggers is documented in the trigger documentation below.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18358-using-cb-triggers

Once we've rewritten our API we'll be improving it further with phpdoc for every trigger so we can better document triggers and their variables.

But how can I manage it, that user2 gets also the connection type of user1 to his connection with him? User1 can also belong to different usergroups.

It's not hardcoded to a specific user. It fires and establishes the connection type when one user accepts the connection request from another user. So if user2 accepts a connection request from user1 it will work for that situation as well.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.333 seconds

Facebook Twitter LinkedIn