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
/
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/
Share Improve this question asked Nov 27, 2019 at 11:16 Jason AkeJason Ake 11 Answer
Reset to default 0Welcome 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/reference/functions/get_current_user_id/ for return values.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744962965a4603499.html
评论列表(0条)