Create Connect Button For Member Search List

5 years 3 months ago #309888 by bins
You previously guided me to create a field I call 'Connected To Me'. This field displays whether a member is connected/not connected to me in a member list.

Here is the code I use:

$cbConnection = new cbConnection( '[user_id]' );

return ( $cbConnection->isConnected( '[cb:userdata field="user_id" user="#me" /]' ) ? 'CONNECTED' : 'NOT CONNECTED' );


How can I edit this so rather than just indicating if connected/not connected, if I am not connected, there is a link/button to connect (instead of Not Connected)?

Please Log in to join the conversation.

5 years 3 months ago #309901 by krileon
Replied by krileon on topic Create Connect Button For Member Search List
Add a button with an onclick or a href with the following URL to establish a connection.

index.php?option=com_comprofiler&view=addconnection&connectionid=USER_ID_HERE

Example as follows.

<a href="index.php?option=com_comprofiler&view=addconnection&connectionid=[user_id]" class="btn btn-success">Request Connection</a>


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.

5 years 3 months ago #309944 by bins
Kyle,

wonderful, as always.

I have used the code as suggested:

$cbConnection = new cbConnection( '[user_id]' );

return ( $cbConnection->isConnected( '[cb:userdata field="user_id" user="#me" /]' ) ? 'CONNECTED' : '<a href="index.php?option=com_comprofiler&view=addconnection&connectionid=[user_id]" class="btn btn-success">Request Connection</a>' );


One issue, though. When I click the button, it shows me as connected with the member, however, on the member page it shows as 'Pending'. Does the code need a parameter to indicate the pending state?

Please Log in to join the conversation.

5 years 3 months ago #309947 by krileon
Replied by krileon on topic Create Connect Button For Member Search List

Does the code need a parameter to indicate the pending state?

Nope, it should say "Connection Pending Acceptance!" unless you've mutual consent turned off in CB > Configuration > Connections in which case it should say "Connection Successfully Added!".


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.

5 years 2 months ago #309979 by bins
Mutual consent is on.

When I click the new connect button, it takes me to their profile and says 'Connection Pending Acceptance!'.

When the other person searches for me (in a list or on my profile), it gives them the option to 'Accept' or 'Reject' me.

When I go to the list and search for them, it says we are connected (not 'awaiting' or 'requested' etc), even though they have not physically accepted me.

Please Log in to join the conversation.

5 years 2 months ago #309989 by krileon
Replied by krileon on topic Create Connect Button For Member Search List

When I go to the list and search for them, it says we are connected (not 'awaiting' or 'requested' etc), even though they have not physically accepted me.

isConnected just checks if a connection exists. Use isConnectionAccepted if you want to make sure the connection was accepted.


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.219 seconds

Facebook Twitter LinkedIn