Skip to content

Instantly share code, notes, and snippets.

@carlodaniele
carlodaniele / remove.toolbar-4.php
Last active February 18, 2016 16:32
Remove Toolbar for all users
<?php add_filter( 'show_admin_bar', '__return_false' ); ?>
@carlodaniele
carlodaniele / remove-toolbar-5.php
Last active May 17, 2017 10:19
Remove Toolbar for all users
<?php
/**
* Remove WordPress Toolbar for all users
*
*/
function myplugin_remove_admin_bar(){
return false;
}
add_filter( 'show_admin_bar' , 'myplugin_remove_admin_bar' );
<?php
/**
* Remove WordPress Toolbar for users not allowed to publish posts
*
* @param bool $show_admin_bar Whether the admin bar should be shown
*/
function myplugin_remove_admin_bar( $show_admin_bar ) {
if( current_user_can( 'publish_posts' ) ){
return $show_admin_bar;
}else{
<?php
function myplugin_customize_toolbar( $wp_admin_bar ){
// your code here
}
add_action( 'admin_bar_menu', 'myplugin_customize_toolbar', 999 );
<?php
/**
* Customize WordPress Toolbar
*
* @param obj $wp_admin_bar An instance of the global object WP_Admin_Bar
*/
function myplugin_customize_toolbar( $wp_admin_bar ){
$user = wp_get_current_user();
if ( ! ( $user instanceof WP_User ) ){
<li id="wp-admin-bar-user-url">
<a class="ab-item" href="http://example.com">
<span class="user-url">My Website</span>
</a>
</li>
<?php
/**
* Customize WordPress Toolbar
*
* @param obj $wp_admin_bar An instance of the global object WP_Admin_Bar
*/
function myplugin_customize_toolbar( $wp_admin_bar ){
$user = wp_get_current_user();
if ( ! ( $user instanceof WP_User ) ){
<?php
/**
* Prints style element
*/
function myplugin_custom_css() {
$output = '<style> #wpadminbar #wp-admin-bar-editor-menu .ab-icon:before { content: "\f322"; top: 2px; } </style>';
echo $output;
}
add_action( 'wp_head', 'myplugin_custom_css' );
@carlodaniele
carlodaniele / frontend-login-form.php
Last active March 31, 2019 01:39
This plugin allows to include a login form into the site front end with a shortcode
<?php
/**
* Setup
*/
function frontend_user_manager_init() {
add_shortcode( 'frontend-login-form', 'frontend_login_form' );
}
add_action('init', 'frontend_user_manager_init');
/**
@carlodaniele
carlodaniele / custom-login-page.php
Created February 27, 2016 16:35
Switch the URL of default login page with the URL of a custom login page
<?php
/**
* Set a custom login page
*
* @param string $url Default login URL
* @param string $redirect Redirect URL on login
* @param bool $force_reauth Whether to force reauthorization
* @link https://developer.wordpress.org/reference/hooks/login_url/
*/
function frontend_login_url( $url, $redirect, $force_reauth ){