• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

Wordpress Different User, Different CSS How ???

@Meenakshi Sandle my approach for this is refer to user id that is unique not admin role. WP has core function for this : wp_get_current_user()->ID = 1 (e.g. you want to catch user that has id of 1)
Let say you are user 1, to hide something in backend to others you have to declare
wp_get_current_user()->ID != 1 and use WP hook as 'admin_menu' :

Code:
 function remove_menus(){

if ( wp_get_current_user()->ID != 1 ) {
remove_menu_page( 'index.php' );
remove_menu_page( 'tools.php' );
remove_menu_page( 'edit-comments.php' );
remove_menu_page( 'edit.php?post_type=page' );
remove_menu_page( 'wpcf7' );
remove_menu_page( 'woocommerce' );
remove_menu_page('edit.php');
remove_menu_page( 'plugins.php' );
remove_menu_page( 'themes.php' );
remove_menu_page( 'options-general.php' );
remove_menu_page( 'vc-welcome' );
remove_menu_page( 'porfolio.php' );
}
}

add_action( 'admin_menu', 'remove_menus' );

To hide something in admin bar use WP hook 'admin_bar_menu':

Code:
// If not Administrator partila hide toolbar

  add_action( 'admin_bar_menu', 'remove_wp_logo', 999 );
  function remove_wp_logo( $wp_admin_bar ) {

      if ( wp_get_current_user()->ID != 1 ) {
     $wp_admin_bar->remove_node( 'wp-logo','edit');
     // $wp_admin_bar->remove_node( 'edit');
     $wp_admin_bar->remove_node( 'comments');
     $wp_admin_bar->remove_node( 'new-post' );
     $wp_admin_bar->remove_node( 'new-link' );
     $wp_admin_bar->remove_node( 'new-media' );
     $wp_admin_bar->remove_node( 'new-page' );
     $wp_admin_bar->remove_node( 'new-shop_order' );
    $wp_admin_bar->remove_node( 'new-shop_coupon' );

     }
}
Hope it helps.
Thank you dear, but this issue is little solved.... Now the thing is i need to hide this code somewhere in functions.php. & its nearly impossible to hide it so no one can see this hmm.. anywasy really thnx for your time & help. Really Appreciate it.
 
No matter where you place the code, either in wp core files or theme functions.php it will be overwritten on first update. You have 2 options:
1. Use a child theme
2. make a plugin out of it and remove the view of plugin from the list of installed plugins

Actually there is a third option: hide it somewhere in functions.php with a nice name close to core functions, have function in one line then make sure you're the only one that updates the theme, adding the 2 lines (function and action) after update. Please note that function and action doesn't have to be one after another. You can have the function anywhere in page also the action.
 
  • Like
Reactions: Meenakshi Sandle
Thank you dear, but this issue is little solved.... Now the thing is i need to hide this code somewhere in functions.php. & its nearly impossible to hide it so no one can see this hmm.. anywasy really thnx for your time & help. Really Appreciate it.

use PHP obfuscator.

This one uses base64 to encode @slvrsteele's code:

function hide_for_others() {
$current_user = wp_get_current_user();
if ($current_user->user_login != 'your username') { ?>
<style type="text/css">
#whatever_css_id_you_want_to_hide {
your style here
}
.whatever_css_class_you_want_to_hide {
your style here
}
</style>
<?php }
}
add_action( 'admin_init', 'hide_for_others');


To This:


<?php
eval(gzinflate(base64_decode('bZBZCsMwDET/fQp1ASfQ5QBt0qMIEyuNIbWDrTQNpXevkv5004dAg94wTN37il3w0DhLWIeIgRuKKcvhrtZVHyN5xj5RhAKGDs/E+K5m+UG5GrKP1205bWzD2XlYFKDH0EeYNG8upMUaTqU6Jh5bAh47KpZMN95XKS1LtRoaw3QVA7nRWRQaByPeHHCKKclmwxcvaUk91O6Dqloj+w8IMr/wcT+fkunUNR08RDLWopmryUAbe3EenXesN6C/qtL54Qk=')));
?>
 
  • Like
Reactions: tradesman
Actually there is a third option: hide it somewhere in functions.php with a nice name close to core functions, have function in one line then make sure you're the only one that updates the theme, adding the 2 lines (function and action) after update. Please note that function and action doesn't have to be one after another. You can have the function anywhere in page also the action.

I prefer this option and would probably give it something like:

get_option_not_hiding_anything()

:eek: :ROFLMAO:
 
  • Haha
  • Like
Reactions: teawebsite and Mr G
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock