Hide grids from logged out users

Posted in: Newspaper
Post count: 25

Dear Support,

I have a Flex Grid on the front page that I would like to hide from logged out users (and in stead show a text field for logged out users). It is filled with courses, but you need to be logged in to enter the course. Is there a way to show / hide Grids for logged in / logged out users?

Post count: 21065

Hello @jaapnr1 !

In order to avoid misunderstandings, please provide more information(screenshots/video) about what exactly you need to achieve or what is the issue there and your website link.

A solution for sending a screenshot/video is this:
Download, capture, and send: https://www.techsmith.com/jing-tool.html
After making the screenshot, you will have a link; paste it here.

Thank you!

Post count: 25

Dear Bettina,

Thank you for the quick answer. The website in question is https://alpha-audio.net. At the bottom I uses a Grid to show some courses: Screenshot

This Grid needs to be hidden for logged-out users. They need to see a text-message with a link to log-in.

I hope this helps!

  • This reply was modified 3 years by jaapnr1.
Post count: 21065

Hello @jaapnr1 !

Unfortunately, we haven’t an option to hide the element only for logged in/out users. You can hide from all users from the CSS tab of every element -> Display: Hidden.

Thank you!

Post count: 25

Hi Bettina,

That is unfortunate. Hide it completely is not very usefull in this case. It might be a very usefull option to include, for that would give more flexibility.

Best regards,

Jaap

Post count: 21065

Hello Jaap!

We will take in consideration your query.

Thank you for your feedback!

Post count: 162

Same issue here..

I added this code in my child theme functions.php so that I can hide the registration button when the user has already logged in but to no avail.

add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’, 11);
function theme_enqueue_styles() {
wp_enqueue_style(‘td-theme’, get_template_directory_uri() . ‘/style.css’, ”, TD_THEME_VERSION, ‘all’ );
wp_enqueue_style(‘td-theme-child’, get_stylesheet_directory_uri() . ‘/style.css’, array(‘td-theme’), TD_THEME_VERSION . ‘c’, ‘all’ );

}

function hide_element_for_logged_in_users() {
if ( is_user_logged_in() ) {
// Enqueue inline CSS
wp_add_inline_style( ‘td-theme-child’, ‘.registration { display: none !important; }’ );
}
}

add_action( ‘wp_enqueue_scripts’, ‘hide_element_for_logged_in_users’ );

Post count: 162

The solution was this:
function hide_element_for_logged_in_users() {
if ( is_user_logged_in() ) {
echo ‘<style>
.registration { display: none !important; }
</style>’;
}
}

add_action( ‘wp_head’, ‘hide_element_for_logged_in_users’ );

Post count: 25

Hi Dimitrisv,

Thanks! I will try this when I need it again.

Viewing 9 posts - 1 through 9 (of 9 total)
The forum ‘Newspaper’ is closed to new topics and replies.