For developers who need to go beyond the level settings, the Member Network Sites Add On offers one action hook and two filter hooks. Use them to run your own code when a member site is created, set site credits in code, or leave some levels out of site creation. This page also covers the default settings the Add On applies to new sites, a custom Manage Sites template, and helper functions.

Add these code examples to your site using a customizations plugin. See How to Add Code to WordPress for help.

Actions

pmpro_network_new_site

Fires after the Add On creates a new site for a member, at checkout or from the Manage Sites page. It runs once the site exists and the member is its administrator. Use it to set options, add content, or activate plugins on the new site.

do_action( 'pmpro_network_new_site', int $blog_id, int $user_id );

Parameters

  • $blog_id: int; The ID of the new site.
  • $user_id: int; The ID of the member who owns the new site.

Example

function my_pmpro_network_new_site( $blog_id, $user_id ) {
	// Set a tagline on every new member site.
	update_blog_option( $blog_id, 'blogdescription', 'A member site on our network' );
}
add_action( 'pmpro_network_new_site', 'my_pmpro_network_new_site', 10, 2 );

Filters

pmpron_site_credits

Filters the number of site credits for a membership level. The value you return overrides the Number of Sites setting on the level wherever the Add On reads it: on the checkout page, when it creates a site, and when it recalculates a member’s credits after a membership change.

apply_filters( 'pmpron_site_credits', mixed $site_credits, int $user_id, int $level_id );

Parameters

  • $site_credits: mixed; The Number of Sites saved for the level. null if the level has never been saved with this Add On active.
  • $user_id: int; The ID of the logged-in user when credits are looked up. This is not always the member being updated, for example when an admin changes a member’s level or a payment completes in the background.
  • $level_id: int; The membership level ID.

Note: If a level has no saved Number of Sites and your filter returns a value, the Add On saves that value as the level’s setting.

Example

function my_pmpron_site_credits( $site_credits, $user_id, $level_id ) {
	if ( 1 == $level_id ) {
		$site_credits = 1;
	} elseif ( 2 == $level_id ) {
		$site_credits = 3;
	}
	return $site_credits;
}
add_filter( 'pmpron_site_credits', 'my_pmpron_site_credits', 10, 3 );

pmpron_non_site_level_array

Filters the list of membership level IDs that skip site creation at checkout. Checkout for these levels doesn’t show the Site Information section, doesn’t require a site name, and doesn’t create a site, even if the level has site credits. The filter runs on the WordPress init hook, so add it before then.

apply_filters( 'pmpron_non_site_level_array', array $pmpro_network_non_site_levels );

Parameters

  • $pmpro_network_non_site_levels: array; Membership level IDs to skip. Default is an empty array.

Note: This filter only affects checkout. Members of these levels still receive the level’s site credits and can add sites from the Manage Sites page.

Example

function my_pmpron_non_site_levels( $levels ) {
	$levels[] = 4;
	return $levels;
}
add_filter( 'pmpron_non_site_level_array', 'my_pmpron_non_site_levels' );

Change or Turn Off the Default New Site Settings

The Add On runs the pmpron_new_blogs_settings() function on the WordPress wp_initialize_site action at priority 20, after WordPress creates the new site’s tables. It runs for every new site created on the network while the Add On is active, not only member sites. It:

  • Sets the site’s tagline to “Change your subtitle”.
  • Renames the category with ID 1 (Uncategorized by default) to “General”, with the slug general.
  • Marks the site as public in the network’s site list.

To keep the WordPress defaults, remove the action. Wrap it in a function on plugins_loaded so it runs after the Add On has added the action:

function my_pmpron_remove_new_site_settings() {
	remove_action( 'wp_initialize_site', 'pmpron_new_blogs_settings', 20 );
}
add_action( 'plugins_loaded', 'my_pmpron_remove_new_site_settings' );

To apply your own settings to every new site, hook your own function to wp_initialize_site. It receives the new site as a WP_Site object:

function my_new_site_settings( $new_site ) {
	update_blog_option( $new_site->id, 'blogdescription', 'Just another site on our network' );
}
add_action( 'wp_initialize_site', 'my_new_site_settings', 20 );

To change settings only on sites created for members, use the pmpro_network_new_site action instead.

Updating Custom Code From Version 0.6.1 or Earlier

Before version 0.6.2, the Add On ran these settings on the deprecated wpmu_new_blog action. If your custom code turned them off with the old hook, it no longer has any effect. Update this line:

remove_action( 'wpmu_new_blog', 'pmpron_new_blogs_settings' );

To this, inside a function hooked to plugins_loaded as shown above:

remove_action( 'wp_initialize_site', 'pmpron_new_blogs_settings', 20 );

The priority (20) is required; remove_action() only removes a callback registered at the same priority. Custom code that calls pmpron_new_blogs_settings() directly with a site ID still works.

Custom Manage Sites Page Template

The Manage Sites page is built from the Add On’s pages/manage-sites.php file. To customize it, copy that file to paid-memberships-pro/pages/manage-sites.php in your child theme or theme. The Add On loads the child theme copy first, then the parent theme copy, then its own file.

Note: Your copy replaces the whole file, which also registers the pmpron_manage_sites shortcode and the redirect for members without credits. Start from the file in the current version of the Add On and keep those functions in place.

Helper Functions

pmpron_getSiteCredits()

Returns the number of site credits for a membership level, after the pmpron_site_credits filter.

pmpron_getSiteCredits( int $level_id );

Parameters

  • $level_id: int; The membership level ID.

pmpron_getBlogsForUser()

Returns an array of the site IDs a member owns through this Add On, in the order they were created. Sites that no longer exist on the network are removed from the list first.

pmpron_getBlogsForUser( int $user_id );

Parameters

  • $user_id: int; The user ID.

pmpron_checkSiteName()

Checks whether a site name and title can be used for a new site, using the WordPress multisite signup rules. Returns true if they can. Otherwise returns false and sets a Paid Memberships Pro error message listing the problems.

pmpron_checkSiteName( string $sitename, string $sitetitle, WP_User $user = null );

Parameters

  • $sitename: string; The site name used in the site address.
  • $sitetitle: string; The site title.
  • $user: WP_User; Optional. The user who will own the site. Defaults to the current user.

pmpron_addSite()

Creates a new site on the network for a member, makes them its administrator, adds it to their list of sites, and fires pmpro_network_new_site. It doesn’t check the site name or the member’s remaining credits, so call pmpron_checkSiteName() and compare against the member’s credits first. Returns the new site ID, a WP_Error if WordPress couldn’t create the site, or false if the user wasn’t found.

pmpron_addSite( string $sitename, string $sitetitle, int $user_id = null );

Parameters

  • $sitename: string; The site name used in the site address.
  • $sitetitle: string; The site title.
  • $user_id: int; Optional. The user who will own the site. Defaults to the current user.

Stored Data

  • Option pmpron_site_credits_{level_id}: The Number of Sites setting for each level.
  • User meta pmpron_site_credits: The member’s current site credits.
  • User meta pmpron_blog_ids: An array of the site IDs the member owns, in the order they were created.
  • User meta pmpron_blog_id: The ID of the member’s first site (their primary site).
  • Constant PMPRO_NETWORK_MANAGE_SITES_SLUG: An older way to set the Manage Sites page by its slug. It’s only used when no page is assigned under Memberships > Settings > Pages.

Last updated on November 19, 2026


Was this article helpful?
YesNo