October 22, 2024
Chicago 12, Melborne City, USA
PHP

Remove button when logged in (wordpress)


I am trying to remove a button for all logged in users on my website. When logged out I have a register button on the start page – which I want to remove when a user log in. Not a menu item – a button on the start page.

I have tried this code in the child theme function file:

function example_function()
{
    if ( is_user_logged_in() ) 
    {
.hide-me {
display: none;
    }
}
add_action('init', 'example_function');
}

However this gives my site critical error.

.hide-me is a css class I use on the button when I edit in elementor page builder.

Not sure what I do wrong. Do you know and can you please help me?



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video