I need help showing a specific menu item if user role is "Affiliate".
Menu Item is "Affiliate Dashboard"
Don't want to use any plugin for such task.
Site is under maintenance mode so I can't show the site, However I've attached screenshot.
Please take a look and help me out.
Thanks
The following code will hide "Affiliate Dashboard" menu item if the current user role is not "affiliate":
The code:
add_action( 'wp_head', 'show_hide_affiliate_menu_item', 500 );
function show_hide_affiliate_menu_item() {
if( ! current_user_can( 'yith_affiliate' ) )
echo '<style> .top-bar-nav #menu-item-11874 { display: none !important } </style>';
}
Code goes in function.php file of your active child theme (or active theme). It should work.
Just write a if condition for do this..Example
if(Auth::user()->has('Affiliate')) {
Affiliate Dashboard
}
But it's only possible when your user have assigned specific role
Related
I am trying to figure out how to change/remove the text under "Products (Varer)" on my Wordpress woocommerce website like in this screenshot:
Any help is appreciated.
According to OceanWP's docs, you can add this function to your functions.php file of the child theme to remove the subheading:
// Remove the Shop page subheading
function my_remove_shop_page_header_subheading( $subheading ) {
if ( is_shop() ) {
$subheading = false;
}
// Return the subheading
return $subheading;
}
add_filter( 'ocean_post_subheading', 'my_remove_shop_page_header_subheading' );
Alternatively, you can add one line of extra css to your website (tested and worked):
.clr .page-subheading {display: none}
Follow this steps to edit/remove sub heading.
Go to Pages > select shop page > Edit.
Under Ocean WP settings choose Title.
Enter your desired subheading or a single space in case you want to remove that altogether.
Note: A single space would remove that line altogether, won't create an empty line as of now.
I am not sure if that would change with theme/plugin updates, but is a good option if you have not created child theme. In case you have created a child theme have a look here: https://docs.oceanwp.org/article/500-remove-the-shop-page-subheading
In the admin page when you press "add new order" there is General Details, Billing Details and Shipping Details:
I would love to hide some these with CSS. I've tried all day but have been able to achieve this unsuccessfully.
I just want to keep the Billing details visible. Is that possible?
This can be done simply with the following hooked function and some specific CSS rules:
add_action('admin_head', 'my_admin_head');
function my_admin_head() {
?>
<style>
.post-new-php.post-type-shop_order #postbox-container-2 .order_data_column_container > .order_data_column:first-child,
.post-new-php.post-type-shop_order #postbox-container-2 .order_data_column_container > .order_data_column:last-child {
display:none !important;
}
</style>
<?php
}
Code goes in function.php file of your active child theme (or active theme).
Tested and works…
I'd like to add a DIV under the title of my Shop page, but ONLY my main shop page.
I added some code in " archive-product.php " but then it display the code on every shop page.
In fact i just need a DIV saying " choose a category below " on the main Shop Page.
Thnaks a lot for your help!
Vince
Instead of overriding archive-product.php template, You can use the following custom hooked function, that will add a custom <div> below the title in shop page only:
add_action( 'woocommerce_archive_description', 'additional_div_in_shop', 5 );
function additional_div_in_shop() {
// Only on "shop" archives pages
if( ! is_shop() ) return;
// Output the div
?>
<div class="shop-below-title"><?php _e( "Choose a category below", "woocommerce" ); ?></div>
<?php
}
Code goes in function.php file of your active child theme (or active theme).
Tested and works.
Related Docs: woocommerce conditional tags
You can add that div conditionally like the following and then the div will be shown only on shop page
if ( is_shop() ) {
echo '<div>Choose a category below</div>';
}
I know this is an old post but, there is a page selected as the shop page for woocommerce. U can simply switch back to classic editor and add a div in the text section of the page u selected in the woocommerce settings. That way u don't need child theme or anything.
I am using the WooCommerce Cost of Goods (Cog's) plugin which add an extra filed to my add new products page so that I may enter the cost of each product so that it is reflected in a profit report. The problem is that I need to have non-admins be able to add products but I do not want them to be able to see the cost of goods fields. The solution would be to hide this field completely from non-admin. Is there a way to do this with a filter or any other way?
You can see screen shots below of where this field is added and the field classes.
.form-field _wc_cog_cost_field
Click to see image 1
Click to see image 2
You could use admin_head hook to add some css to wp admin.
<?php
add_action( 'admin_head', 'my_admin_css');
function my_admin_css() {
$user = wp_get_current_user();
if ( $user->roles[0] != 'administrator' ):
?>
<style type="text/css">
.form-field._wc_cog_cost_field {
display: none !important;
}
</style>
<?php
endif;
}//end function
I would like to remove downloads menu from my account page.
How can I do this? Is it any hook to remove a specific item from the menu?
Thanks.
Go to WooCommerce > Settings > Advanced and remove the entry for Downloads in the Account endpoints section, just leave it blank. And the menu will not be visible anymore.
You will need this lightly customized this code snippet:
function custom_my_account_menu_items( $items ) {
unset($items['downloads']);
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'custom_my_account_menu_items' );
This code goes on function.php file of your active child theme (or theme) or in any plugin file.
This code is tested and working
[data-tab="downloads"] {
display: none!important;
}