-
-
Save doozy/386ac2709837001b2ccf3bf169d7d6d4 to your computer and use it in GitHub Desktop.
[wishlist]Force creating a wishlist for guest or user that without default wishlist.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Force creating a wishlist for guest or user that without default wishlist. | |
add_action( 'wp', 'tinvwl_set_sharekey' ); | |
function tinvwl_set_sharekey() { | |
// Check if Wihslist class loaded. | |
if ( ! class_exists( 'TInvWL_Wishlist' ) ) { | |
return; | |
} | |
// Get sharekey for a default wishlist. | |
$wl = new TInvWL_Wishlist(); | |
$sharekey = $wl->get_sharekey(); | |
// Create a wishlist in case it doesn't exists. | |
if ( empty( $sharekey ) ) { | |
$user_id = get_current_user_id(); | |
$sharekey = $wl->add_user_default( $user_id ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment