Codifigata – Content Login Gate lets you restrict the entire content of a post/page, or just part of it (for example download buttons), to logged-in users, showing a login button to logged-out visitors in place of the restricted content.
Two usage modes
[cdfg_login_gate]...[/cdfg_login_gate] shortcode, which can be added in the Gutenberg “Shortcode” block. Useful for hiding only one section of the content (e.g. download buttons) while keeping the rest of the post visible.Two display modes (Settings Content Login Gate)
Features
min_height and label shortcode attributes to customize each individual restricted area.Developer filters
cdfg_login_url (string $login_url, string $redirect)
Filters the base URL of the login page. Default: home_url( '/login/' ).
cdfg_button_label (string $label)
Filters the default label of the login button.
cdfg_post_types (array $post_types)
Filters the list of post types on which the “Restricted access” meta box is shown. Default: array( 'post', 'page' ).
Example:
add_filter( 'cdfg_login_url', function( $url, $redirect ) {
return home_url( '/sign-in/' );
}, 10, 2 );
add_filter( 'cdfg_post_types', function( $post_types ) {
$post_types[] = 'product';
return $post_types;
} );