Disclaimer first this has nothing to do with Bricks Builder… I am here looking for some recommendations.
A client of mine, we have built a client resource center, as part of their website, they would like to have the pages password protected, however they would also like to have the ability to direct link pass the password protection from their service application, third party software…
The only plugin I can find that says that it claims to do everything I am asking for is https://passwordprotectwp.com. The only issue I see with this plugin is that it requires the Pro plugin to work on Custom Post Types, and that comes with a hefty price tag, for something that seems like it should be fairly easy…
I’m curious if anyone else has experience with this or knows of other plugins worth consideration?
@901422183
We did end up going with PPWP for our password management system, and even though there was the price tag involved with that, it actually turned out to be a very nice plugin for our needs.
I was able to set up passwords at the category level pages, which instead of setting up as an archive template, the site was built using elementor, so I created pages, and included the posts element to displaying resources, which worked fine for us, because each of the resources are actually downloadable materials and not individual pages that also need rendering.
Once the individual pages were protected, PPWP also allows us to set up bypass urls, which worked great for our third party application, which already requires user login to access, to be able to set up links directly to the user levels determined resources. So each system can now link to each other while not being interrupted by a password request.
So in the end I can recommend PPWP. Hopefully this helps your project.
Thank you very much. For me it is too expensive, I just want to secure some pages of my own portfolio site with the option to send a magic link that unlocks all pages at once. Furthermore I do not want the users to get prompted on the new page, they should enter the password when clicking on the button/link. But 600$ for the lifetime deal is to expensive for that personal use case… @RisynOne
I know I’m late to the party but I stumbled upon this by accident.
To contribute something to this post, I wanted to share this idea.
You could also use something like this if you want to show a post/page/CPT only to logged-in users:
// Add custom meta box
add_action('add_meta_boxes', function () {
add_meta_box(
'login_required_meta_box',
'Access Control',
'render_login_required_meta_box',
['post', 'page','cpt'],
'side',
'high'
);
});
function render_login_required_meta_box($post) {
// Get the current value
$value = get_post_meta($post->ID, 'login-required', true);
// Use nonce for security
wp_nonce_field('save_login_required_meta_box', 'login_required_meta_box_nonce');
// Render the checkbox
?>
<label>
<input type="checkbox" name="login_required_field" value="1" <?php checked($value, '1'); ?> />
Require login to view this page
</label>
<?php
}
// Save the checkbox value as custom field
add_action('save_post', function ($post_id) {
// Check nonce
if (!isset($_POST['login_required_meta_box_nonce']) || !wp_verify_nonce($_POST['login_required_meta_box_nonce'], 'save_login_required_meta_box')) {
return;
}
// Check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
// Check user capability
if (!current_user_can('edit_post', $post_id)) return;
// Save or delete the custom field
if (isset($_POST['login_required_field'])) {
update_post_meta($post_id, 'login-required', '1');
} else {
delete_post_meta($post_id, 'login-required');
}
});
To use this in the frontend you should be able to just use a condition or generally this script:
add_action('template_redirect', function () {
if (is_singular(['post', 'page'])) {
$requires_login = get_post_meta(get_the_ID(), 'login-required', true);
if ($requires_login && !is_user_logged_in()) {
wp_redirect(wp_login_url(get_permalink()));
exit;
}
}
});
In all fairness I just wrote this down with some help of ChatGPT and cross-read it but if I am not mistaken, this should do the trick.