First of all, I am new to wordpress and creating one application in wordpress. I am using one plugin, now in that plugin for particular role like student, teacher site goes into the admin panel.
Now, I want to customize admin panel look & feel for selected users like student & teacher. I have already tried "AG Custom Admin", but didn't satisfied completely. So, I want to make custom css.
Is there any way that I can is like,
if(is_admin())
{
// Use Default CSS
}
else
{
// My Custom CSS
}
If yes, then where can I use this condition? I am using wordpress 3.8
Any help will be very appericiable,
Thanks.
Checkout current_user_can() method:
http://codex.wordpress.org/Roles_and_Capabilities#Capabilities
That method could be used like this:
if ( current_user_can('moderate_comments') ) {
wp_enqueue_style( 'Teacher Styles', 'teacherStyles.css' );
}
else{
wp_enqueue_style( 'Default Styles', 'defaultStyles.css' );
}
Related
i need to make some blocks(widgets) like the same of WordPress dashboard widgets. that means if we dragged a widget to another position it wouldn't change after refreshing the page. is there any way for the same.?? i want some blocks or widgets (functioning like dashboard widgets) in my custom plugin. :)
I believe you need this:
function your_dashboard_widgets() {
global $wp_meta_boxes;
wp_add_dashboard_widget('custom_help_widget', 'Theme Support', 'your_widget_callback');
}
add_action('wp_dashboard_setup', 'your_dashboard_widgets');
function your_widget_callback() {
echo '<p>Welcome!</p>';
}
I am trying to hide the WPBakery Page Builder tab for all the roles except admin.
I tried using adminimize plugin to do so, but still the tab is visible in all the roles. https://wordpress.org/plugins/adminimize/
I also tried the below code but I can only do it for admin and not other roles.
if ( !is_admin() ) {
function custom_menu_page_removing()
{
remove_menu_page('vc-general'); //vc
}
add_action( 'admin_init', 'custom_menu_page_removing' );
}
vc-welcome will hide menu from all other roles except admin so no need to write if condition, You can try below code
function custom_menu_page_removing() {
remove_menu_page('vc-welcome');
}
add_action( 'admin_init', 'custom_menu_page_removing' );
I think there is a better way to do this straight from the WPBakery Page Builder Settings. You can follow the menu from the image below and set the Settings options to disabled.
WPBakery Page Builder > Role Manager
I am trying to use reudx frame as option panel for a plugin. On this plugin, there is a widget which will be activated based on the settings of option panel.
For example, if the option panel, particular switch id is set to on /true /yes, then the widget should show on the widget manager section. Otherwise widget will not show in the widget manager section.
I have used following code, to get values to widget class file.
if ($GLOBALS['redux_demo']['myoption'] = true ) {
add_action( 'widgets_init', 'register_mywidget' );
}
$redux_demo is global setting for redux_options.
myoption is the id of the section, where the setting stores data
when i do print_r i get the value on $GLOBALS['redux_demo']['myoption'] as 1
but, when it put the code as above, the widget won't disapper, when the setting is marked to '0'.
please help.
Try use:
if ($GLOBALS['redux_demo']['myoption']) {
add_action( 'widgets_init', 'register_mywidget' );
}
I want to hide a text-widget in wordpress using conditional tags when users are logged in. I've learned that using
is_user_logged_in()
shows a text widget when users are logged in.
If you're comfortable changing the code where the widget is outputted you could use the is_user_logged_in() function. Something like this:
<div id="widget_area">
<?php
if ( is_user_logged_in() ) {
// show nothing
} else {
dynamic_sidebar('widget_name');
}
?>
</div>
The downside being that this is now hard coded and you might have to add this function in a few different files.
So, I'll recommend to use Widget Logic plugin. Widget Logic is a very popular plugin that will help you accomplish your goal. While Widget Logic can help you do much more than hide or show a widget to logged in/logged out users.
Once installed and activated, you will see an empty box at the bottom of each widget. (Appearance > Widgets)
I have a multisite WP with Buddypress and BP Multi Network.
The sites are being created automatically (data is coming from external system).
The problem is I want to show only the Activity tab in the menu and I want to rename it as well. I have created bp-custom.php and this is its content:
<?php
function bp_change_tabname() {
global $bp;
$bp->bp_nav['activity']['name'] = 'Duvar';
$bp->bp_nav['members'] = false;
}
add_action( 'bp_setup_nav', 'bp_change_tabname', 999 );
?>
It is not working though. It seems like the content of bp-custom is irrelevant.
Any ideas?
To remove a nav item from the navigation array you can use bp_core_remove_nav_item(). For example:
function my_remove_tabs() {
bp_core_remove_nav_item( $parent_id );
}
add_action( 'bp_setup_nav', 'my_remove_tabs' );
Where $parent_id is the slug of the parent navigation item.
To customise the tab labels, you could use a language file. See the Customising Labels, Messages and URLs article for more info on how and why.