Hiding Request/Listing Button

Just wanted to share this snippets to hide the two buttons on the top right of ExpertHive theme based on user role. It works for my influencer marketplace site as I do not want brands to post a listing nor influencers post a request:

/* When no users are logged in, show both buttons */
body:not(.logged-in) .hp-menu__item--request-submit,
body:not(.logged-in) .hp-menu__item--listing-submit {
    display: block;
}

/* For all logged in users, hide both buttons initially */
body.logged-in .hp-menu__item--request-submit,
body.logged-in .hp-menu__item--listing-submit {
    display: none;
}

/* When a subscriber is logged in, only show the hp-menu__item--request-submit button */
.role-subscriber .hp-menu__item--request-submit {
    display: block !important;
}

/* When a contributor is logged in, only show the hp-menu__item--listing-submit button */
.role-contributor .hp-menu__item--listing-submit {
    display: block !important;
}
/* When no users are logged in, show both buttons */
body:not(.logged-in) .hp-menu__item--request-submit,
body:not(.logged-in) .hp-menu__item--listing-submit {
    display: block;
}

/* For all logged in users, hide both buttons initially */
body.logged-in .hp-menu__item--request-submit,
body.logged-in .hp-menu__item--listing-submit {
    display: none;
}

/* When a subscriber is logged in, only show the hp-menu__item--request-submit button */
.role-subscriber .hp-menu__item--request-submit {
    display: block !important;
}

/* When a contributor is logged in, only show the hp-menu__item--listing-submit button */
.role-contributor .hp-menu__item--listing-submit {
    display: block !important;
}
1 Like

Hi,

Thank you for sharing this code.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.