Skip to content

Instantly share code, notes, and snippets.

@doozy
Created December 6, 2019 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doozy/386ac2709837001b2ccf3bf169d7d6d4 to your computer and use it in GitHub Desktop.
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.
// 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