/** * Create a set of default wishlists for every new user. * * Remove this snippet if the wishlist plugin adds this feature natively. */ add_action( 'user_register', 'my_seed_default_wishlists', 20 ); function my_seed_default_wishlists( $user_id ) { // Bail if the wishlist plugin is not active. if ( ! class_exists( '\SaveToWishlist\Classes\Factories\Collections' ) ) { return; } // Edit these names. The FIRST one becomes the user's default wishlist. $wishlist_names = array( 'Wishlist', 'Backlog', 'Played' ); // Only ever seed a user once. if ( get_user_meta( $user_id, '_my_default_wishlists_seeded', true ) ) { return; } $collections = \SaveToWishlist\Classes\Factories\Collections::instance(); $first_id = 0; foreach ( $wishlist_names as $index => $name ) { $created = $collections->save_collection( array( 'user_id' => $user_id, 'name' => $name, 'description' => '', 'status' => 'publish', 'is_default' => 0 === $index ? 1 : 0, 'is_public' => 0, ) ); if ( 0 === $index && ! empty( $created->id ) ) { $first_id = (int) $created->id; } } // Make sure the first wishlist ends up as the default one. if ( $first_id ) { $collections->update_default_wishlist( $user_id ); $collections->update_default_wishlist( $user_id, 1, $first_id ); } update_user_meta( $user_id, '_my_default_wishlists_seeded', 1 ); }
Pending Plays >

Neopets Relaunch? A Review

Share this:

For those of you who have been living under a rock, Neopets is a virtual pet community where you can adopt, customise and play with your virtual buddies. It has been around since 1999 and most of us millennials created an account at some point.  When I heard Neopets was back with a new ownership…

Read More