Jump to content

[Share] How to set Password for Individual Project Page

Recommended Posts

To set password for individual project page, you can follow these.

You can do same with Product, Event, Blog...

#1. First, edit individual project page > Add a Code Block

image.thumb.png.edee5a34c9510d6fadc08b49eff0b5a8.png

#2. Add this code into Code Block

<style>
  #siteWrapper {
   display: none;
}
a.btn.btn--border.theme-btn--primary-inverse.sqs-button-element--secondary.second-button {
 display: none; 
}
  #check-pw-block {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}
#siteWrapper {
   display: none;
}
a.btn.btn--border.theme-btn--primary-inverse.sqs-button-element--secondary.second-button {
 display: none; 
}
  </style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
  $(document).ready(function () {
  var $div = $(`
  <div id="check-pw-block">
    Enter Password:
    <input type="text" value="" id="inputPW" /><br />
    <p id="check-pw-error" style="display: none; color: red">Wrong password</p>
    <button onclick="protectPasscode()">Check</button>
  </div>
  `).appendTo("body");
});
function protectPasscode() {
  let password = 123;
  var inputPW = $("#inputPW")[0];
  var siteWrapper = $("#siteWrapper");
  var pwErrorText = $("#check-pw-error");
  var checkPwBlock = $("#check-pw-block");
  var buttonContact = $("a.btn.btn--border.theme-btn--primary-inverse.sqs-button-element--secondary.second-button");
  if (inputPW.value == password) {
    siteWrapper.show();
    buttonContact.css("display", "inline-block");
    checkPwBlock.hide();
  } else {
    siteWrapper.hide();
    buttonContact.hide();
    checkPwBlock.show();
    pwErrorText.show();
  }
}
</script>

image.png.a40d29063f6f1ce779f8d729055ff1e8.png

#3. Result

When users access page, they will see this

image.png.bf26bd74d15392fc9cea15088ccea4d8.png

#4. To change password, you can find this line

image.png.9de92bd1350f84580ef7193a591bd7fc.png

 

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • Replies 0
  • Views 384
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Posted Images

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.