@@ -43,7 +43,8 @@ function wp_user_manager_install( $network_wide = false ) {
4343function wpum_generate_pages () {
4444 $ is_block_editor = function_exists ( 'use_block_editor_for_post_type ' ) && use_block_editor_for_post_type ( 'page ' );
4545 // Generate login page
46- if ( ! wpum_get_option ( 'login_page ' ) ) {
46+
47+ if ( ! wpum_get_option ( 'login_page ' ) || FALSE === get_post_status ( wpum_get_option ( 'login_page ' )[0 ] ) ) {
4748 $ login_content = $ is_block_editor ? '<!-- wp:wpum/login-form /--> ' : '[wpum_login_form psw_link="yes" register_link="yes"] ' ;
4849
4950 $ login = wp_insert_post (
@@ -59,7 +60,7 @@ function wpum_generate_pages() {
5960 wpum_update_option ( 'login_page ' , [ $ login ] );
6061 }
6162 // Generate password recovery page
62- if ( ! wpum_get_option ( 'password_recovery_page ' ) ) {
63+ if ( ! wpum_get_option ( 'password_recovery_page ' ) || FALSE === get_post_status ( wpum_get_option ( ' password_recovery_page ' )[ 0 ] ) ) {
6364 $ psw_content = $ is_block_editor ? '<!-- wp:wpum/password-recovery-form /--> ' : '[wpum_password_recovery login_link="yes" register_link="yes"] ' ;
6465
6566 $ psw = wp_insert_post (
@@ -75,7 +76,7 @@ function wpum_generate_pages() {
7576 wpum_update_option ( 'password_recovery_page ' , [ $ psw ] );
7677 }
7778 // Generate password recovery page
78- if ( ! wpum_get_option ( 'registration_page ' ) ) {
79+ if ( ! wpum_get_option ( 'registration_page ' ) || FALSE === get_post_status ( wpum_get_option ( ' registration_page ' )[ 0 ] ) ) {
7980 $ reg_content = $ is_block_editor ? '<!-- wp:wpum/registration-form /--> ' : '[wpum_register login_link="yes" psw_link="yes"] ' ;
8081
8182 $ register = wp_insert_post (
@@ -91,7 +92,7 @@ function wpum_generate_pages() {
9192 wpum_update_option ( 'registration_page ' , [ $ register ] );
9293 }
9394 // Generate account page
94- if ( ! wpum_get_option ( 'account_page ' ) ) {
95+ if ( ! wpum_get_option ( 'account_page ' ) || FALSE === get_post_status ( wpum_get_option ( ' account_page ' )[ 0 ] ) ) {
9596 $ account_content = $ is_block_editor ? '<!-- wp:wpum/account-page /--> ' : '[wpum_account] ' ;
9697
9798 $ account = wp_insert_post (
@@ -107,7 +108,7 @@ function wpum_generate_pages() {
107108 wpum_update_option ( 'account_page ' , [ $ account ] );
108109 }
109110 // Generate password recovery page
110- if ( ! wpum_get_option ( 'profile_page ' ) ) {
111+ if ( ! wpum_get_option ( 'profile_page ' ) || FALSE === get_post_status ( wpum_get_option ( ' profile_page ' )[ 0 ] ) ) {
111112 $ profile_content = $ is_block_editor ? '<!-- wp:wpum/profile-page /--> ' : '[wpum_profile] ' ;
112113
113114 $ profile = wp_insert_post (
@@ -257,3 +258,20 @@ function wpum_run_install() {
257258 set_transient ( '_wpum_activation_redirect ' , true , 30 );
258259
259260}
261+
262+ /**
263+ * Install default data when new site is added.
264+ * @param object $site
265+ * @return void
266+ */
267+ function wpum_multisite_new_site ( $ site ){
268+ if ( ! function_exists ( 'is_plugin_active_for_network ' ) ) {
269+ require_once ( ABSPATH . '/wp-admin/includes/plugin.php ' );
270+ }
271+ if ( is_plugin_active_for_network ( 'wp-user-manager/wp-user-manager.php ' ) ) {
272+ switch_to_blog ( $ site ->blog_id );
273+ wpum_run_install ();
274+ restore_current_blog ();
275+ }
276+ }
277+ add_action ( 'wp_initialize_site ' , 'wpum_multisite_new_site ' );
0 commit comments