Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[SOLVED] Protecting a profile with a password?

  • OldLodgeSkins
  • OldLodgeSkins
  • OFFLINE
  • Posts: 119
  • Thanks: 5
  • Karma: 2
  • Add-ons
11 years 2 weeks ago - 10 years 11 months ago #235503 by OldLodgeSkins
[SOLVED] Protecting a profile with a password? was created by OldLodgeSkins
Hi,

I'm wondering if this would be possible or not...

The idea would be to let a user define a password in his account, and then say (probably with a radio button yes / no) if he wants people to give the password before they can see his profile. I.e. when you go to the profile, you're being asked for the password, if you don't have it you don't see the profile. This includes public visitors.
I've looked at the privacy plug-in it doesn't seem to be meant for this.
Any idea how I can achieve this? Is this even possible? From what I've seen so far with my pro subscription it seems CB can do things I didn't even suspect... So I'm guessing it might be doable.

Thanks.

Seb.
Last edit: 10 years 11 months ago by OldLodgeSkins.

Please Log in or Create an account to join the conversation.

  • OldLodgeSkins
  • OldLodgeSkins
  • OFFLINE
  • Posts: 119
  • Thanks: 5
  • Karma: 2
  • Add-ons
11 years 2 weeks ago - 11 years 1 week ago #235504 by OldLodgeSkins
Replied by OldLodgeSkins on topic Protecting a profile with a password?
Hum... I'm wondering if this wouldn't be a job for AutoActions again...
Something along the lines of if (user wants password protection) then request password before displaying profile... With an onBeforeUserProfileDisplay trigger... Am I on the right track?

Edit: so far I have a code action with onBeforeUserProfileDisplay trigger, condition: cb_secret => not empty, and some JS code to prompt for the "magic word".
This works as expected, the prompt comes up before the profile is displayed, and passed into a variable. Now how do I check that variable against the value of cb_secret?
And then if it's correct just let things continue as normal, if not redirect somewhere else, that would be the easy part...
Last edit: 11 years 1 week ago by OldLodgeSkins.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48474
  • Thanks: 8281
  • Karma: 1443
11 years 1 week ago - 11 years 1 week ago #235549 by krileon
Replied by krileon on topic Protecting a profile with a password?
This can be done using a Redirect action in CB Auto Actions on the before profile display trigger. You need to be sure "User" is set to "User" so it'll use the user object of the viewing user and not the user object of the displayed user. You can then add your conditionals as needed. You'll probably also want to condition to make sure the profile does not belong to the user trying to view it so they don't get locked out of their own profile. Example as follows.

Type: Redirect
Triggers: onBeforeUserProfileDisplay
User: User
Access: Everybody
Conditional 1: [cb_secret] Is Empty
Conditional 2: [user_id] Not Equal To [var1_id]
URL: index.php


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.
Last edit: 11 years 1 week ago by krileon.
The following user(s) said Thank You: OldLodgeSkins

Please Log in or Create an account to join the conversation.

  • OldLodgeSkins
  • OldLodgeSkins
  • OFFLINE
  • Posts: 119
  • Thanks: 5
  • Karma: 2
  • Add-ons
11 years 1 week ago - 11 years 1 week ago #235562 by OldLodgeSkins
Replied by OldLodgeSkins on topic Protecting a profile with a password?
Hi,

Ok so I was leaning in the right direction, Auto Actions is the way to go here again... But doing it this way, how do you ask the visitor if he knows the "secret word" or not?
The idea is to let only the people who have been given the secret word access to that particular user's profile. So each user defines his secret word - if he wishes to - letting only people he gives that secret word to access his profile.

Thanks.

Seb.

Edit: or are you suggesting to combine the two, a code action to ask for the password and then a redirect action?
Last edit: 11 years 1 week ago by OldLodgeSkins.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48474
  • Thanks: 8281
  • Karma: 1443
11 years 1 week ago #235571 by krileon
Replied by krileon on topic Protecting a profile with a password?
You don't, they'd have to supply it as a CB field, which you condition against in your auto action. If you need something that elaborate you'll need custom coding with server side validation.


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.
The following user(s) said Thank You: OldLodgeSkins

Please Log in or Create an account to join the conversation.

  • OldLodgeSkins
  • OldLodgeSkins
  • OFFLINE
  • Posts: 119
  • Thanks: 5
  • Karma: 2
  • Add-ons
11 years 1 week ago #235573 by OldLodgeSkins
Replied by OldLodgeSkins on topic Protecting a profile with a password?
Yes that's the idea, the user enters his secret word in a CB field in his profile, that's the one I called "cb_secret" in my example...

Right now here's what I have, in my code event:
Code:
function checkSecret(){ var x; var secret=prompt("Do you know the magic word?"); if (secret=='[cb_secretword]'){ x="You do know the magic word!"; } else { x="hum-hum-hum! You didn't say the magic word!"; } alert(x); } checkSecret();

It seems to be working, I get the right alert depending on whether or not I gave the right word. So now I guess with a JS redirect in case the secret word provided isn't the right one, I should be done...

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum