記錄一下woocommerce hook的筆記
//一般wp_login的hook
function so_26675676_your_function($user_login, $user) { // your code } add_action('wp_login', 'so_26675676_your_function', 10, 2);
//woocommerce login hook,你可以自訂_wp_http_referer參數
add_filter( 'woocommerce_login_redirect', 'krex_redirect'); add_filter( 'woocommerce_registration_redirect', 'krex_redirect'); function krex_redirect( $redirect_to ) { if ( ! empty( $_REQUEST['_wp_http_referer'] ) ){ $ref = wp_unslash( $_REQUEST['_wp_http_referer'] ); } return $ref; }
//shortcode
[woo_social_login redirect_url="轉頁的網址"]
/*---------------------------------------------------- ------------------------*/ // redirects for login / logout /*----------------------------------------------------------------------------*/ add_filter('woocommerce_login_redirect', 'login_redirect'); function login_redirect($redirect_to) { $location = $_SERVER['HTTP_REFERER']; wp_safe_redirect($location); exit(); } add_action('wp_logout','logout_redirect'); function logout_redirect(){ $location = $_SERVER['HTTP_REFERER']; wp_safe_redirect($location); exit(); }
- https://www.skyverge.com/blog/advanced-woocommerce-social-login/
- https://github.com/woothemes/woocommerce/commit/014e31952828377bf7a1ebf4e812a43d0bcefa67#commitcomment-3351995
沒有留言:
張貼留言
留個話吧:)