
When managing exclusive content, such as member-only resources or webinar materials, manually restricting access to specific users can be a hassle. By placing the Login Check Module on your page, you can automatically verify if a user is logged in. If they are not, the module will instantly redirect them to a designated authentication or registration page.


When managing exclusive content, such as member-only resources or webinar materials, manually restricting access to specific users can be a hassle. By placing the Login Check Module on your page, you can automatically verify if a user is logged in. If they are not, the module will instantly redirect them to a designated authentication or registration page.
The primary objective of this module is to automate content protection and optimize the user experience.
This guide covers everything from the setup in the Design Manager to managing the module within the page editor.
To enable the advanced verification logic, perform the following:
Create a new page from the HubSpot "Content" menu. Search for the module in the left sidebar of the editor and drag and drop it at the top of your page.
Use the sidebar panel in the page editor to define the module's behavior:
Create a "New Module" in the HubSpot Design Manager and paste the following code into each respective section.
This is the field definition. It consists of a repeater field (Items) and style setting fields (Styles).
[
{
"default": {
"content_id": null,
"href": "",
"type": "EXTERNAL"
},
"display_width": null,
"id": "9b439ed7-146f-9c8e-5b57-c264daba12ca",
"label": "redirect_url",
"locked": false,
"name": "redirect_url",
"required": false,
"supported_types": [
"EXTERNAL",
"FILE",
"CONTENT",
"BLOG",
"CALL_TO_ACTION",
"PAYMENT",
"EMAIL_ADDRESS",
"PHONE_NUMBER",
"WHATSAPP_NUMBER"
],
"type": "url"
},
{
"allow_new_line": false,
"display_width": null,
"id": "cccffad9-3274-a676-1d0f-23f8154bd351",
"label": "message",
"locked": false,
"name": "message",
"required": false,
"type": "text"
}
]{% if not has_contact and not is_in_editor %}
<!-- より厳密な検証を行う包括的な実装 -->
{% set contact_verified = false %}
{% set contact_data = {} %}
<!-- Step 1: 基本的なコンタクト存在確認 -->
{% if contact and contact.email and contact.email != "" %}
{% set contact_verified = true %}
{% set contact_data = contact %}
{% endif %}
<!-- Step 2: request_contactでの補完確認 -->
{% if not contact_verified and request_contact.contact_id %}
{% set contact_verified = true %}
{% set contact_data = request_contact %}
{% endif %}
<!-- Step 3: 結果に基づく処理 -->
{% if contact_verified %}
<!-- コンタクト検知成功 - ツール表示 -->
<div class="member-area">
<p>{{ module.message }}</p>
</div>
{% else %}
<!-- コンタクト未検知 - リダイレクト処理 -->
{% set redirect_url = module.redirect_url.href|default('https://www.hirose.com/corporate/ja/') %}
<div class="redirect-notice">
<p>Redirecting to authentication...</p>
</div>
<script>
// 即座にリダイレクト
setTimeout(function() {
window.location.href = '{{ redirect_url }}';
}, 1000);
</script>
{% endif %}
{% endif %}No. The code includes a check for is_in_editor, ensuring that administrators are not redirected while editing the page.
Yes. By adjusting the millisecond value in the setTimeout function within the code, you can freely control how long the system waits before redirecting the user.
Users who are confirmed as logged in will not be redirected. Instead, the area will display the "Success Message" you configured in the editor.
We can customize this sample to match your specific business requirements.
Book Free ConsultationPut it on Trello!Need a fix for HubSpot, CMS, or GAS? Post it on Trello.
Development Requests Here