[SOLVED] Button on profile to store viewers user id

1 week 4 days ago - 1 week 3 days ago #297294 by davidmarshall15
Hello,

Is it possible to create a button to be displayed on the users profile, when pressed it stores the user id of the viewing user.

I had the idea of creating an hidden integer field to have the column added to #__comprofiler, but how to add a button and store the viewers user id I have no idea, is it even possible?

It would be even better if when the button is pressed, a row could be inserted directly into a custom table, storing both the profile user id and viewers user id, then the hidden integer field is not required and no after update trigger on #__comprofiler is not required.

Thanks
David
1 week 4 days ago #297297 by davidmarshall15
Hope this helps clarify the original post, having something similar to the Request Connection button, that can be done using CB core/plugins.



The Request Connection button is a good example as it is processing both user id's.
Attachments:
1 week 4 days ago #297301 by krileon
Yes, that's doable. You'll need to create a CB Auto Action usage to do the storage. Leave Triggers as None and set User to User. If you want to update a field value on click then you can use a Field action for that. Now on the Global tab of your auto action is a URL to directly execute your action. Your button would link to that. To display a button on profile you'll need to use a Custom HTML field and write the HTML for that.

Not entirely sure what you're needing this for though. Could you better describe the purpose or usecase of needing this as there maybe a better or automated way of doing it. For example the CB Last Views Tab already tracks who views your profile.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
--
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 EST to 4:00 PM EST. 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.
The following user(s) said Thank You: davidmarshall15
1 week 4 days ago - 1 week 4 days ago #297306 by davidmarshall15
I can get the auto action working from a profile link, to run a query and insert a row but I cannot capture the user id of the profile being viewed. I am always getting the user id of the viewer who clicks the button.

I have tried [var1] [var2] [var3] without much success
I have tried [user_id] and [cb:userdata field="user_id" user="#me" /], this works with connection triggers for example, but in this case both values are the viewers id

The purpose is to create a nudge / poke type button, I only need to insert the row into a none CB table and after that I can deal with the notification etc.
1 week 4 days ago #297307 by krileon
For that you'll just want to pass that with the URL. When configuring your Custom HTML field add to the URL something like &profile=[user_id] then in your auto action use [get_profile] to substitute it in. Since you're storing this to the database be sure to sanitize it before doing so. So for example you'd be safe to store the following.

[cb:parse function="clean" method="int"][get_profile][/cb:parse]

Be sure to turn on format functions under the parameters tab of your auto action for the above format function to work.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
--
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 EST to 4:00 PM EST. 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.
1 week 4 days ago #297308 by davidmarshall15
Yes that is working for me, thank you for your help.
The following user(s) said Thank You: krileon
Moderators: beatnantkrileon
Time to create page: 0.198 seconds
Facebook Twitter Google LinkedIn