WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#34739 closed enhancement (fixed)

New filters to extend Add New Site Network Screen (wp-admin/network/site-new.php)

Reported by: igmoweb Owned by: jeremyfelt
Milestone: 4.5 Priority: normal
Severity: normal Version: 4.4
Component: Networks and Sites Keywords: has-patch commit
Focuses: administration, multisite Cc:

Description

Some plugins may need to add new fields in this screen. I attach a patch with two new hooks:

  • network_after_site_new_form : Allows to add new fields before submit button is displayed and form tag is closed
  • network_site_new_blog_meta : We can pass the value of those fields to the meta array before creating a blog

Attachments (3)

extend_site_new.patch (1.8 KB) - added by igmoweb 4 years ago.
Extend site-new.php patch
34739.patch (1.2 KB) - added by igmoweb 4 years ago.
Removed network_site_new_blog_meta filter. Can make use of wpmu_new_blog instead
34739.2.patch (769 bytes) - added by ocean90 3 years ago.

Download all attachments as: .zip

Change History (10)

@igmoweb
4 years ago

Extend site-new.php patch

#1 @igmoweb
4 years ago

And here's a use case: https://gist.github.com/igmoweb/9db3bc38a632b717d01c

It creates a Theme dropdown in that screen. The Super Admin can select the theme before creating the blog.

#2 @jeremyfelt
4 years ago

  • Keywords needs-refresh added
  • Milestone changed from Awaiting Review to Future Release

Thanks for the ticket and patch, @igmoweb, this is definitely worth thinking about. #15389 is related, though I like that this ticket is more focused on just the new site form. I thought there was another related ticket, but nothing is popping up for me at the moment.

I'm not sure about the filter for $meta. Anything hooking in to network_after_site_new_form could probably also hook into wpmu_new_blog to look for additional POST data.

@igmoweb
4 years ago

Removed network_site_new_blog_meta filter. Can make use of wpmu_new_blog instead

#3 @igmoweb
4 years ago

Yeah, I thought about it better after I uploaded the first patch. I've removed it in the latest patch ( 34739.patch).

Also updated the use case: https://gist.github.com/igmoweb/9db3bc38a632b717d01c

Thanks.

@ocean90
3 years ago

#4 @ocean90
3 years ago

  • Keywords has-patch commit added; needs-refresh removed
  • Milestone changed from Future Release to 4.5
  • Type changed from feature request to enhancement

34739.2.patch is a refresh of 34739.patch. It removes "after" from the filter name so we have the same terminology as for user_new_form.

Any objections @jeremyfelt?

#5 @jeremyfelt
3 years ago

None from me - 34739.2.patch looks good.

#6 @jeremyfelt
3 years ago

  • Owner set to jeremyfelt
  • Resolution set to fixed
  • Status changed from new to closed

In 36555:

Multisite: Add a hook to the end of the Add Site form.

The network_site_new_form action can be used to extend the new site form.

Props igmoweb, ocean90.
Fixes #34739.

#7 @neelakansha85
3 years ago

A suggestion: This would display all the themes in multisite network even if they are not enabled by super admins. With the below change it can be useful in the front end as well on wp-signup.php page.
Here is a code change I would recommend:

<?php foreach ( $themes as $theme ): ?>
    <?php if($theme->is_allowed()):?>
        <option value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>"><?php echo $theme->title; ?></option>
    <?php endif; ?>
<?php endforeach; ?>

Also I am working on something related to breaking the create new site page into steps https://github.com/neelakansha85/nsd-site-setup-wizard not sure if this would be helpful feature for the core.

Note: See TracTickets for help on using tickets.