Support » Plugin: WooCommerce » [Plugin: WooCommerce – excelling eCommerce] Woocommerce: Admin Redirect – disable for non Customers

Viewing 9 replies - 1 through 9 (of 9 total)
  • I do not know how to do it exactly but inside woocommerce_function.php is a fucntion: function woocommerce_process_login() and at the bottom is a line: wp_redirect(get_permalink(woocommerce_get_page_id(‘myaccount’)));

    Solution number one is to change the word ‘myaccount’ to something else.
    I cannot recommend this because it is a nightmare to keep track on own changes every time there is an official update.

    Solution number 2 may be!
    May be it is possible to cancel the function woocommerce_process_login() and replace it with your own.

    There is a system of elimination/replacing of functions in the theme- system parent/child. if a plugin function is considered to be a child theme function, then you should be able to copy the function in to your theme functions.php and add your changes here.

    but now I’m guessing

    what about that:
    /**
    * Login and Registration
    *
    * @see woocommerce_process_login()
    * @see woocommerce_process_registration()
    */
    add_action( ‘init’, ‘woocommerce_process_login’ );
    See All hooks Here

    Can we use this action to change woocommerce redirection:
    add_action( ‘init’, ‘woocommerce_process_login’ );

    anyone managed to resolve the super annoying issue above, no administrators can login into wordpress dashboard via wp-admin since i activated this stupid woocommerce plugin! Come woothemes get your act together.

    I am having this problem too.

    I only have 1 use set up (Admin) and I cannot access my Dashboard. It redirects to Woocommerce My Account.

    I don’t know what to do.

    Please help.

    Hi DizzyDi,

    I don’t know where you installed your WordPress. As my experience, I run my WordPress on a server which uses cPanel. And it is very confusing because when you quickinstall WordPress, the default username you set up is not administrator. That’s why you can’t access the Dashboard.

    The simplest solution I learned is:
    1. Install a WordPress on your local machine.
    2. Go to its database at localhost/phpmyadmin.
    3. Export wp_usermeta and wp_users from your local machine.
    4. Override wp_usermeta and wp_users on your remote server with the two you get from your local machine.
    5. Log in with the username and password.

    Now the username you use is the administrator and you can access the Dashboard.

    Hope this helps!

    If you login to your site via FTP and change the name of the woocommerce folder inside your plugins folder (wp-content>plugins) to something else, it will disable the plugin and you can at least access your dashboard. That’s as far as I have gotten though – anyone else come up with a solution?

    I have a multisite and it seems that woocommerce replaces default wordpress user roles with their own. Each site that I have activated woocommerce the roles have been changed of deleted.

    I don’t know if this is related but if anybody know how to resolve this please let me know.

    Thanks

    maybe this helps someone.
    i kind of had the same issue (wanting to redirect admins to the dashboard and everybody else to the my-account page) so i came up with this one
    (to put in your own functions file)

    /**remove wooocommerce's own login processing to replace with our own to enable redeirection by role */
    	remove_action('init','woocommerce_process_login');
    	add_action('init','msci_woo_after_login_redirect');
    	/**the below is a copy of woocommerce_process_login with a couple of bits added */
    	function msci_woo_after_login_redirect() {
    		global $woocommerce;
    
    		if ( ! empty( $_POST['login'] ) ) {
    
    			$woocommerce->verify_nonce( 'login' );
    
    			try {
    				$creds = array();
    
    				if ( empty( $_POST['username'] ) )
    					throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . __( 'Username is required.', 'woocommerce' ) );
    				if ( empty( $_POST['password'] ) )
    					throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . __( 'Password is required.', 'woocommerce' ) );
    
    				if ( is_email( $_POST['username'] ) ) {
    					$user = get_user_by( 'email', $_POST['username'] );
    
    					if ( isset( $user->user_login ) )
    						$creds['user_login'] 	= $user->user_login;
    					else
    						throw new Exception( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . __( 'A user could not be found with this email address.', 'woocommerce' ) );
    				} else {
    					$creds['user_login'] 	= $_POST['username'];
    				}
    
    				$creds['user_password'] = $_POST['password'];
    				$creds['remember']      = true;
    				$secure_cookie          = is_ssl() ? true : false;
    				$user                   = wp_signon( $creds, $secure_cookie );
    
    				if ( is_wp_error( $user ) ) {
    					throw new Exception( $user->get_error_message() );
    				} else {
    					/**********************************************************************************************
    					*	added to original function to redirect depending on user roles]
    					***********************************************************************************************/
    					/*********************************************************************
    					*	set your redirects depending on user role
    					*	note: some users may have more than one role in which case you may want
    					*	to run a foreach loop or something
    					*	instead of using $roleRedirect[$user->roles[0]] below
    					***********************************************************************/
    					$roleRedirect['super_admin']='/wp-admin';
    					$roleRedirect['administrator']='/wp-admin';
    					/**********************************************************************************************
    					*	END->[added to original function to redirect depending on user roles]
    					**********************************************************************************************/
    
    					if ( ! empty( $_POST['redirect'] ) ) {
    						$redirect = esc_url( $_POST['redirect'] );
    					} 
    
    					/**********************************************************************************************
    					*	added to original function to redirect depending on user roles]
    					***********************************************************************************************/
    					elseif(isset($roleRedirect[$user->roles[0]])){
    						$redirect = esc_url($roleRedirect[$user->roles[0]]);
    					}
    					/**********************************************************************************************
    					*	END->[added to original function to redirect depending on user roles]
    					**********************************************************************************************/
    					elseif ( wp_get_referer() ) {
    						$redirect = esc_url( wp_get_referer() );
    					} else {
    						$redirect = esc_url( get_permalink( woocommerce_get_page_id( 'myaccount' ) ) );
    					}
    
    					wp_redirect( apply_filters( 'woocommerce_login_redirect', $redirect, $user ) );
    					exit;
    				}
    			} catch (Exception $e) {
    				$woocommerce->add_error( $e->getMessage() );
    			}
    		}
    	}

    may not be perfect but may be a starting point…..dunno

    scotcrop

    (@scottcropper)

    For a possible solution for redirects on woocommerce login/registration forms see

    https://github.com/woothemes/woocommerce/commit/014e31952828377bf7a1ebf4e812a43d0bcefa67#commitcomment-3351995

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: WooCommerce – excelling eCommerce] Woocommerce: Admin Redirect – disable for non Customers’ is closed to new replies.