Skip to main content

Posts

Showing posts from May, 2020

How to create custom wordpress logout button(wp_logout_url) in wordpress?

custom wordpress logout button(wp_logout_url) in wordpress <li class="menu-logout"><a href="<?php echo wp_logout_url(); ?>"><span><i class="fa fa-sign-out"></i></span>Logout</a></li> Or <li class = "signOut" > <? php wp_logout (); ?> </li> add_action ( 'wp_logout' , 'auto_redirect_external_after_logout' ); function auto_redirect_external_after_logout (){ wp_redirect ( 'http://redirect-url' ); exit (); }

How to redirect user on different page accounding to user (Customer, editor, admin, subscriber and etc)?

How to redirect user on different page accounding to user (Customer, editor, admin, subscriber and etc)? function wc_custom_user_redirect( $redirect, $user ) { // Get the first of all the roles assigned to the user $role = $user->roles[0]; $dashboard = admin_url(); $myaccount = get_permalink( wc_get_page_id( 'myaccount' ) ); if( $role == 'administrator' ) {     //Redirect administrators to the dashboard     $redirect = $dashboard; } elseif ( $role == 'shop-manager' ) {     //Redirect shop managers to the dashboard     $redirect = $dashboard; } elseif ( $role == 'editor' ) {     //Redirect editors to the dashboard     $redirect = $dashboard; } elseif ( $role == 'author' ) {     //Redirect authors to the dashboard     $redirect = $dashboard; } elseif ( $role == 'customer' || $role == 'subscriber' ) {     //Redirect customers and subscribers to the "My Account" page     if(has_active_subscription($

Check if User Has Already Purchased Product in woo-commerce?

WooCommerce: Check if User Has Already Purchased Product function start_deal_button(){ ob_start(); global $user; global $product; $current_user = wp_get_current_user(); if(!is_user_logged_in()) { echo "<a href='".site_url().'/my-account'."' class='start-deal-button'>Start Deal  <i class='fa fa-handshake'></i></a>"; } if((has_active_subscription() || wc_customer_bought_product( $current_user->user_email, $current_user->ID,'9011')) && (is_user_logged_in())){      echo "<a href='".site_url().'/start-deal'."' class='start-deal-button'>Start Deal  <i class='fa fa-handshake'></i></a>";; } if(!(has_active_subscription() || wc_customer_bought_product( $current_user->user_email, $current_user->ID,'9011')) && (is_user_logged_in())){     echo "<a href='".s

How to remove and unremove options(Download, Account Detail, Payment methods) from my account in woo-commerce?

How to remove and keep options(Download, Account Detail, Payment methods)  from my account in woo-commerce? add_filter ( 'woocommerce_account_menu_items', 'misha_remove_my_account_links' ); function misha_remove_my_account_links( $menu_links ){ //unset( $menu_links['edit-address'] ); // Addresses unset( $menu_links['dashboard'] ); // Remove Dashboard //unset( $menu_links['payment-methods'] ); // Remove Payment Methods unset( $menu_links['orders'] ); // Remove Orders //unset( $menu_links['downloads'] ); // Disable Downloads //unset( $menu_links['edit-account'] ); // Remove Account details tab //unset( $menu_links['customer-logout'] ); // Remove Logout link return $menu_links; }