Wordpress

Non adming redirect to home page. 
Write this before headers called:
if( !current_user_can( 'manage_options' ) )
{
wp_redirect( site_url() );  exit;

}

Redirect after login to Dashboard for admin and the rest to Home page
Add this under theme/functions.php:
function acme_login_redirect( $redirect_to, $request, $user  ) {
return ( is_array( $user->roles ) && in_array( 'administrator', $user->roles ) ) ? admin_url() : site_url();
}
add_filter( 'login_redirect', 'acme_login_redirect', 10, 3 );

Login/logout menu link

add below code in theme function.php
//Add login/logout link to naviagation menu
function add_login_out_item_to_menu( $items, $args ){

//change theme location with your them location name
if( is_admin() ||  $args->theme_location != 'primary' )
return $items;

$redirect = ( is_home() ) ? false : get_permalink();
if( is_user_logged_in( ) )
$link = '<a href="' . wp_logout_url( $redirect ) . '" title="' .  __( 'Logout' ) .'">' . __( 'Logout' ) . '</a>';
else  $link = '<a href="' . wp_login_url( $redirect  ) . '" title="' .  __( 'Login' ) .'">' . __( 'Login' ) . '</a>';

return $items.= '<li id="log-in-out-link" class="menu-item menu-type-link">'. $link . '</li>';
}add_filter( 'wp_nav_menu_items', 'add_login_out_item_to_menu', 50, 2 );

use below code snippet for login form in a page
$args = array(
'echo'           => true,
'remember'       => true,
'redirect'       => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI']. "/dashboard",
'form_id'        => 'loginform',
'id_username'    => 'user_login',
'id_password'    => 'user_pass',
'id_remember'    => 'rememberme',
'id_submit'      => 'wp-submit',
'label_username' => __( 'Username' ),
'label_password' => __( 'Password' ),
'label_remember' => __( 'Remember Me' ),
'label_log_in'   => __( 'Log In' ),
'value_username' => '',
'value_remember' => false

);

<?php wp_login_form( $args ); ?>

Use below code snippet in functions.php to hide + - in quantity

add_filter( 'woocommerce_is_sold_individually', 'wc_remove_all_quantity_fields', 10, 2 );
function wc_remove_all_quantity_fields( $return, $product ) {
    return( true );
}
add_filter( 'woocommerce_product_tabs', 'wcs_woo_remove_reviews_tab', 98 );
function wcs_woo_remove_reviews_tab($tabs) {
 unset($tabs['reviews']);
 return $tabs;
}

Use the below plugin to show Variations in radio button instead of dropdown on product page
WC Variations Radio Buttons

How to hide Reviews Tab in products page Woocommerce.
Add the below code under function.php
add_filter( 'woocommerce_product_tabs', 'wcs_woo_remove_reviews_tab', 98 );
function wcs_woo_remove_reviews_tab($tabs) {
 unset($tabs['reviews']);
 return $tabs;

}

Nav Menu Role Plug-in- This is a wonderful to manage Wordpress Navigation menu across all users and roles.

Query to get WP Users information
select u.display_name, u.user_email, u.id,um.meta_value PhoneNumber from wp_users u join wp_usermeta um on u.id=um.user_id where um.meta_key = 'phone1' and u.id=43

Briefly unavailable for scheduled maintenance. check back in a minute. wordpress
Quick Fix: Wait for few minutes, WP will automatically remove this error. This is not an error don't panic, this is just a message from WP site while updating your plugins etc. Even if after waiting for few minutes this message still appears go to root folder and delete .maintenance file which was created by WP.

For more detailed information follow this link:

http://www.wpbeginner.com/wp-tutorials/how-to-fix-briefly-unavailable-for-scheduled-maintenance-error-in-wordpress/

Happy coding!

How to use WP Shortcut Code in php file
echo do_shortcode('[wp_jdt id="UserData"]');

Change Photo When Change Product Variation
In the list of product variations click the little plus sign in the image placeholder, upload an image and “insert into article”. Repeat for every variation that should have a distinct image. On the product page the image will automatically change when you select a variation.



No comments:

Post a Comment

- Thanks For Your comment