How to create sub site in wordpress multisite programmatically?

With wpmu_create_blog() function, we can create subsites easily. Add the following code in your form submit wpmu_create_blog ( ‘your_domain’, ‘/subsite_path’, ‘Title of Subsite’, ‘1’ ); NB: if your site url is https://www.example.com then your_domain is should be example.com Ref: https://www.krishaweb.com/how-to-programmatically-create-new-site-in-wordpress-multisite-within-60-minutes/

Multisite – Get current post id

try this $sites = get_sites(); global $switched; /** @var WP_Site $site */ foreach ($sites as $site) { if ( $site->archived || $site->spam || $site->deleted ) { continue; } switch_to_blog( $site->blog_id ); $all_posts = get_posts(‘category=-3&numberposts=6&orderby=post_name&order=DSC’); ?> <ul> <?php foreach($all_posts as $post) : setup_postdata($post);?> <li> <a href=”https://wordpress.stackexchange.com/questions/354427/<?php echo get_page_link($post->ID); ?>” title=”<?php echo $post->post_title; ?>”><?php echo $post->post_title; ?></a> … Read more

WordPress Multisite user activation hook from email

As discussed in the comments the fix is to put your wpmu_activate_user hook into a must-use plugin under /wp-content/mu-plugins/. The problem is that the email’s activation link handler, wp-activate.php, defines define( ‘WP_INSTALLING’, true ); (I guess to cover the case it’s running in the context of a newly provisioned site?) and wp-load will not load … Read more

All pages have 302 redirect, which I can’t remove

Welcome! Because you are using multisite, there are a few other places your site may have the WWW active. I would look in the following: wp-config.php under “DOMAIN_CURRENT_SITE”. info wp-config.php under “WP_HOME” and/or “WP_SITEURL” info Inside the database under the “{prefix}_site” (wp_site) table info Inside the database under the “{prefix}_blogs” (wp_blogs) table info Failing those … Read more

Multisite custom user activation emails – html

Per the filter’s documentation, the $content should be formatted for use by wp_mail(). In the wp_mail() documentation, I find this: The default charset is based on the charset used on the blog. The charset can be set using the wp_mail_charset filter. So it appears you need to explicitly allow WordPress to send HTML mail. See … Read more

Buddypress on Multisite – Member List

BP on multisite can be quite complicated. If you network-activated BP, then afaik the users will be available on all ‘blogs’. There are several ways to config a BP > multisite install. There are a couple of plugins that may help, for example: https://buddydev.com/plugins/buddypress-multi-network/ More info from the BP codex: https://codex.buddypress.org/getting-started/installation-in-wordpress-multisite/

Add custom user profile field to default WordPress MultiSite registration form

I finely made it work this way: // Sending custom field data to $meta add_filter(‘add_signup_meta’, ‘sb_add_signup_meta’); function sb_add_signup_meta($meta) { if( isset( $_POST[‘phone_number’] ) ) { $phone_number = filter_var( $_POST[‘phone_number’], FILTER_SANITIZE_NUMBER_INT ); $meta[‘phone_number’] = $phone_number; return $meta; } else return $meta; } // Updating user meta on user activation. Works only if user chose registration without … Read more