Our Experience With WPUltimo Hooks

Note: This article was written based on WPUltimo version 1.x. Since then WPUltimo 2.x has been released. Hence, some of the items mentioned in here might be out of date or simply not apply at all.

WPUltimo is the only plugin of it’s kind. But, unfortunately, its hooks and filters are very poorly documented . Since we’ve been using it for various projects recently we’ve learned a few things. So, in this article we’ll try to share what we’ve discovered – hopefully some of you will find it useful. We definitely wished we knew some of these things earlier – we would have saved ourselves a lot of time!

Action Hook: wu_signup_header

You would think that with a name like this, that you can use this hook to insert or inject data into the top of the sign up forms. And you would be right. But it does it on EVERY SCREEN of the sign up form – in most cases this is NOT what you want.

I suspect you can use the $_GET vars to see which screen you’re on and output data that way.

Additionally, if you have styled the signup forms to have a colored background of any kind then you’ll notice that any output you send with this hook will end up with a white(ish) bottom border 1 px wide. So prepare to style your output to remove it.

add_action( 'wu_signup_header', array( $this, 'wu_before_signup_form' ) ) ;

function wu_before_signup_form() {
	echo '<h1 style="Color: White; Padding:1em; border-bottom-width:0px;">Test of wu_signup_header hook</h1>';

Action Hook: wp_ultimo_after_site_creation

This hook is called just after a new site has been created – either when a user has signed up for a new subscription or has created a new site from within their dashboard/subscription.

It is NOT called if the admin adds a new site from the SITES screen.

When this hook is called, you can assume that the site is blank and no data has yet been copied over from a template site. For most use cases, this hook seems to be useless. Instead, the mucd_after_copy_data hook seems to be a more useful one.

But in case you need it, here’s the stub code:

add_action( 'wp_ultimo_after_site_creation', array( $this, 'wp_ultimo_after_site_creation' ), 10, 1 ) ;

function wp_ultimo_after_site_creation( $user_id ) {
	switch_to_blog( $to_site_id ) ;
	add_option('esm_needs_initializing', true); // Do the thing here.

Action Hook: mucd_after_copy_data

This hook is called after a site has been created in wp-ultimo and data copied over from the template site. If you need to update that data, this is a good hook to do so.

add_action( 'mucd_after_copy_data', array( $this, 'mucd_after_copy_data' ), 10, 2 )

function mucd_after_copy_data( $from_site_id, $to_site_id ) {
	switch_to_blog( $to_site_id ) ;
	add_option('esm_needs_initializing', true); // Do the thing here.

This hook is NOT called if the admin adds a new site from the SITES screen. But it is called if the user creates a new site from inside their dashboard while WPUltimo is active (in additional to new sites created during the signup process of course).

The way we use this hook is to just set an option that lets us know we need to set up our data later. This allows WPUltimo to completely finish up its processing before we start to do ours. We then use the admin_init hook to check for this option and complete our setup.

A lot of times the functions you might expect to exist while the mucd_after_copy_data hook is running just isn’t available. This is especially true if you’re using functions from other plugins. So it’s just better to do your specific things later in the WP initialization sequence if you can.

Other Notes

Plugins that are multisite aware will hook into the wp_insert_site and wpmu_new_blog (deprecated) hooks to create their tables and such when a new site is created. However, when this happens under WPUltimo, not all the WordPress tables actually exist at the time. We’re not quite sure why this is the case but it can cause warnings in the debug.log file.

For example, the OPTIONS table for the subsite will not be present when these hooks are fired under WPULTIMO. So any attempt to insert data into the options table will result in a warning in the debug.log file. Many plugins will thus throw these warnings whenever a subsite is created – and there’s little you can do about it other than to apply a custom fix to the plugin to do the inserts later.

Was This Article Useful? Or do you have questions or comments about it (or our products & services)? We'd love to hear from you!

Please enter your name.
Please enter a message.
You must accept the Terms and Conditions.
Please check the captcha to verify you are not a robot.

Automatic Notification Of New Articles

Sign up to get automatic notifications of new articles.  This is a different list than our standard list - you only get new articles once a week (usually on Mondays).  No other emails will be sent unless you sign up for our general list as well.

Posted in