Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:

When switching to client account from My Account page (feature provided by Sales Agent for WooCommerce plugins) and using Domain Per language WPML settings, the action does not works and redirects backs to my account page.

Solution:

- Backup the site completely first to prevent any issues or better test this on a staging site first.

- Open the wp-content\plugins\sales-agent-for-woocommerce\includes\admin\classes\user\wc-user-switching.php file

- Around line 143, replace the following code:

} else {
	wp_safe_redirect( add_query_arg( $args, admin_url() ), 302, self::$application );
}

- With the following code:

} else {							
	$redirect_to = admin_url();
	// WPML Workaround for compsupp-6847
	if ( class_exists('Sitepress') ) {
		$my_account_page = wc_get_page_id( 'myaccount' );
		if ($my_account_page) {
			$redirect_to = get_permalink($my_account_page);
		}								
	}
	wp_safe_redirect( add_query_arg( $args, $redirect_to ), 302, self::$application );
}

Relevant Documentation:
N/A

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 16 replies, has 2 voices.

Last updated by Subash Chandra Poudel 1 year, 11 months ago.

Assisted by: Subash Chandra Poudel.

Author Posts
June 27, 2023 at 8:20 am #13900297

Subash Chandra Poudel

Thank you for the details. I have escalated the issue to our team to see if this could be addressed from our end.

I will send you an update here as soon as we have an update however that could take some time.

Thank you for your patience and co-operation in the meantime.

July 4, 2023 at 11:22 am #13940325

Fabio Antonio Troietto

Hi,

have a news for me?

Thank you

July 4, 2023 at 3:28 pm #13942783

Subash Chandra Poudel

Hi there,

We don't have any update yet! Since the issue has been escalated to our Compatibility team lets wait for an update from the team.

However since this is an incompatibility issue with plugin that is not compatible with WPML yet and is an edge case issue it might take some time for our team to fully test and send a feedback. Thank you for your patience and co-operation in the mean time.

July 7, 2023 at 4:49 pm #13969613

Subash Chandra Poudel

Hi there,

We have an update here!

We have an workaround now, please try the following and see if it helps with the issue:

- Backup the site completely first to prevent any issues or better test this on a staging site first.

- Open the wp-content\plugins\sales-agent-for-woocommerce\includes\admin\classes\user\wc-user-switching.php file

- Around line 143, replace the following code:

} else {
	wp_safe_redirect( add_query_arg( $args, admin_url() ), 302, self::$application );
}

- With the following code:

} else {							
	$redirect_to = admin_url();
	// WPML Workaround for compsupp-6847
	if ( class_exists('Sitepress') ) {
		$my_account_page = wc_get_page_id( 'myaccount' );
		if ($my_account_page) {
			$redirect_to = get_permalink($my_account_page);
		}								
	}
	wp_safe_redirect( add_query_arg( $args, $redirect_to ), 302, self::$application );
}

Regards,
Subash