Block WP-Admin Area from Non-Administrators
add_action( ‘admin_init’, function() { if ( ! current_user_can( ‘administrator’ ) ) { wp_redirect( home_url() ); exit; } } );Continue reading
Join 2,000,000+ Professionals who use WPCode to Future-Proof Their Websites!
add_action( ‘admin_init’, function() { if ( ! current_user_can( ‘administrator’ ) ) { wp_redirect( home_url() ); exit; } } );Continue reading
function show_loggedin_function( $atts ) { global $current_user, $user_login; get_currentuserinfo(); add_filter(‘widget_text’, ‘do_shortcode’); if ($user_login) return ‘Welcome ‘ . $current_user->display_name . ‘!’; else return ‘Login‘; } add_shortcode( ‘show_loggedin_as’, ‘show_loggedin_function’ );Continue reading
function fulano_prevent_future_type( $post_data ) { if ( $post_data[‘post_status’] == ‘future’ ) { $post_data[‘post_status’] = ‘publish’; } return $post_data; } add_filter(‘wp_insert_post_data’, ‘fulano_prevent_future_type’); remove_action(‘future_post’, ‘_future_post_hook’);Continue reading
add_action( ‘admin_head’, function() { // Add CSS code below. ?> .wpcode-header-top {display:none;} <?php });Continue reading
add_action( ‘admin_head’, function() { // Add CSS code below. ?> /* background color */ .wpat #wpwrap {background: #F5F5F7;} /* wphave submenu arrow */ body.wpat.wpat-menu-left-expand #adminmenu li.wp-has-submenu a.menu-top .wp-menu-name:before {display:none;} <?php });Continue reading
// Disable the Plugin and Theme Editor if ( ! defined( ‘DISALLOW_FILE_EDIT’ ) ) { define( ‘DISALLOW_FILE_EDIT’, true ); }Continue reading
function pd_edd_pre_update_user_profile( $user_id, $userdata ) { // How many characters should the password be? $length = 8; $password = isset( $_POST[‘edd_new_user_pass1’] ) ? $_POST[‘edd_new_user_pass1’] : ”; if ( ! empty( $password ) && ( strlen( $password ) < $length )…Continue reading
/* Remove the ‘Delete’ option from the Payment List Quick Action * This can require a fine tuning of the user roles, typically handeled in a plugin * Example: http://wordpress.org/plugins/user-role-editor/ * * Source of snippet: https://easydigitaldownloads.com/support/topic/custom-payment-history-view-per-user-role/ */ function ck_edd_remove_order_trash_action( $row_actions,…Continue reading
function kjm_modify_user_verification_url_expiration( $url ) { // EDD default is ‘+24 hours’. ‘days’ also works $url = add_query_arg( ‘ttl’, strtotime( ‘+48 hours’ ), $url ); return $url; } add_filter( ‘edd_get_user_verification_url’, ‘kjm_modify_user_verification_url_expiration’ );Continue reading
function edd_hidden_callback( $args ) { global $edd_options; if ( isset( $edd_options[ $args[‘id’] ] ) ) $value = $edd_options[ $args[‘id’] ]; else $value = isset( $args[‘std’] ) ? $args[‘std’] : ”; $size = ( isset( $args[‘size’] ) && ! is_null( $args[‘size’]…Continue reading