0

I have a site where users can claim a business listing. The listings that are not claimed all have the same author. Once they claim them the author becomes the owner of the business. The button sadly does not get removed, that is built in the theme and the theme owner said that will not be added to development.

So I am looking for a code snippet that will inject some CSS onto the pages if the author of the page is not id=2 (that is the author id) This CSS would hide the class of the button which is .claim

There is also a custom field used if that is easier to target for the injection of the field.

Any help or ideas would be greatly apperciated

https://rezrising.org/

1 Answer 1

0

Welcome to Stack Exchange!

In your theme's function.php, you can add this code:

add_filter('body_class', function($classes) {
    $classes[] = 'author-' . get_current_user_id();

    return $classes;
});

This will add a CSS class with the current author's ID to <body> which you can then target:

.author-2 .widget_bt_claim_widget {
    display: none;
}

See https://developer.wordpress.org/reference/functions/get_current_user_id/ for return values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.