Hide Dashboard menu from Subscriber in WP

If you want hide Dashboard menu from Subscriber role user and just want to show their Profile in back end access than its easy to achieve by adding few lines below code in your active theme functions.php file .
with use of this script you no need to use any plugins for hide Dashboard from Subscriber user. its easy to achieve without use of any plugin.


function wplshide_custom_admin_dashboard_links() {

global $parent_file;
if ( ! current_user_can( ‘edit_posts’) && is_user_logged_in()) {
remove_menu_page( ‘index.php’);
remove_menu_page( ‘separator1’ );

if ( ‘index.php’ == $parent_file ) {
if ( headers_sent() ) {
echo ‘<meta http-equiv=”refresh” content=”0;url=’ . admin_url( ‘profile.php’ ) . ‘”>’;
echo ‘document.location.href=”‘ . admin_url( ‘profile.php’ ) . ‘”‘;
} else {
if ( wp_redirect( admin_url( ‘profile.php’ ) ) ) {


add_action( ‘admin_head’, ‘wplshide_custom_admin_dashboard_links’ );

jQuery Script – href # target navigate like one page template use

Using jQuery script move navigation to particular section on same page when click on anchor link which href attribute set like  href=”#about”


<a href=”#about” class=”page-scroll”>About Us</a>

About us Html Section

About us content area

jQuery Script

jQuery(function ($) {
‘use strict’;

jQuery(function ($) {
‘use strict’;
$(‘a.page-scroll’).bind(‘click’, function(event) {
var $anchor = $(this);
$(‘html, body’).stop().animate({scrollTop: $($anchor.attr(‘href’)).offset().top -62}, 1000);


if (window.location.hash){
$(‘html, body’).stop().animate({scrollTop: $(window.location.hash).offset().top -62}, 1000);


Add addtional CSS JS script file in child theme

add_action(‘wp_enqueue_scripts’, ‘ls_head_styles_scripts’, 20 );
function ls_head_styles_scripts() {
wp_register_script(‘ls-custom-script’, get_stylesheet_directory_uri().’/js/ls_custom.js’,array(),”,true);
wp_localize_script(‘ls-custom-script’, ‘ls_ajax_script’, array( ‘lsajaxurl’ => admin_url( ‘admin-ajax.php’)));

// localize lsajaxurl variable to use in jQuery ajax  post to post request on wordpress

to use it call ls_ajax_script.lsajaxurl

Restrict WP User from WP backend logging and profile edit

Restrict WordPress user from Wp back end admin panel login and also restrict from edit profile in back end side.


just put below few line code in your active theme funcstions.php file


add_action( ‘admin_init’, ‘custom_wpadmin_blockusers_init’ );
function custom_wpadmin_blockusers_init() {
if ( !current_user_can( ‘activate_plugins’ ) ) {
wp_redirect( home_url() );


Wp Backend side add additional field in User profile add edit

To add additional field in WordPress admin backend side User profile add edit screen add below scripting in your current using Wp theme functions.php file



/* start Back end extra User profiel field */

add_action( ‘show_user_profile’, ‘extra_user_profile_fields’ );
add_action( ‘edit_user_profile’, ‘extra_user_profile_fields’ );
add_action( “user_new_form”, “extra_user_profile_fields” );

function extra_user_profile_fields( $user ) {
$auto_approve = get_the_author_meta( ‘auto_approve’, $user->ID);
$user_verify_status = get_the_author_meta( ‘user_verify_status’, $user->ID);
<h3><?php _e(“Extra profile information”, “blank”); ?></h3>
<table class=”form-table”>
<th><label for=”auto_approve”><?php _e(“Auto Approve Post”); ?></label></th>
<select name=”auto_approve” id=”auto_approve” style=”width:180px”>
<option value=”0″ <?php selected( $auto_approve, 0); ?>>No</option>
<option value=”1″ <?php selected( $auto_approve, 1); ?>>Yes</option>
<th><label for=”user_verify_status”><?php _e(“Ac Verification”); ?></label></th>
<select name=”user_verify_status” id=”user_verify_status” style=”width:180px”>
<option value=”inactive” <?php selected( $user_verify_status, ‘inactive’); ?>>Not Verified</option>
<option value=”active” <?php selected( $user_verify_status, ‘active’); ?>>Verified</option>

<?php }

add_action( ‘personal_options_update’, ‘save_extra_user_profile_fields’ );
add_action( ‘edit_user_profile_update’, ‘save_extra_user_profile_fields’ );
add_action( ‘user_register’, ‘save_extra_user_profile_fields’ );

function save_extra_user_profile_fields( $user_id ) {
if ( !current_user_can( ‘edit_user’, $user_id ) ) { return false; }
update_user_meta( $user_id, ‘auto_approve’, $_POST[‘auto_approve’] );
update_user_meta( $user_id, ‘user_verify_status’, $_POST[‘user_verify_status’] );



WP Backend side profile edit required email error remove

To hide / remove Wp profile edit error as required field value not enter add below few line scripting in your current theme functions.php file


// remove empty required email error from backend user profile edit
function wpse_ls_empty_email_error( $arg ) {
if ( !empty( $arg->errors[’empty_email’] ) ) unset( $arg->errors[’empty_email’] );
add_action( ‘user_profile_update_errors’, ‘wpse_ls_empty_email_error’ );



When it help full

In wordpress website when you allow user to register without email id and in some cases User Administrator need to edit user profile from WP back end site.


WP user login by Email id and user name without plugin

In WordPress to make it easy for User as Login by user name as well as by email id is very easy by just adding below full lines code in your active theme functions.php files.

function login_via_email_address($username) {
$user = get_user_by(’email’,$username);
$username = $user->user_login;
return $username;

function change_username_with_email_wps_login_text($text){
if(in_array($GLOBALS[‘pagenow’], array(‘wp-login.php’))){
if ($text == ‘Username’){$text = ‘Username / Email’;}
return $text;
add_filter( ‘gettext’, ‘change_username_with_email_wps_login_text’ );