Since version 1.6.2, WP Ultimo allows super admins to make use of a Search and Replace API, which can empower them to automate even more aspects of the site creation workflow.

This API allows the super admin to search for a given piece of text and automatically replace it with another piece of text. This can be done visually on the WP Ultimo Settings -> Network Settings, but its true power comes when using it with custom code.

For example, when creating a contact form on a Site Template, instead of entering an admin email, the network admin can enter a placeholder text, like {{replace_with_client_email}}, for example (the curly braces aren’t necessary, but they make replaceable strings easier to spot).

Then, using the Search and Replace API, WP Ultimo can search for that placeholder and replace it with the client’s email. To do that, just add something like the code below to the functions.php file of your main site’s active theme or inside a custom plugin network-activated. We will use the WU_Signup()->get_transient(false) function to retrieve all the information entered by the user on the sign-up forms.

add_filter('wu_search_and_replace_on_duplication', function($replace_list, $from_site_id, $to_site_id) {
 
  switch_to_blog( get_current_site()->blog_id );
 
    /**
     *
     * Transient carries:
     *
     * 'plan_freq' : The billing frequency chosen by the user (1, 3 or 12);
     * 'plan_id' : The ID of the plan choosen by the user;
     * 'template' : The ID of the site to be used as a template (0 for the default WordPress site);
     * 'blog_title' : The title choosen to the user's site;
     * 'blogname' : The slug of the user's site (the slug portion of yournetwork.com/slug);
     * 'user_name' : Username choosen by the user;
     * 'user_email' : User email entered by the user;
     * 'coupon' : Coupon code name, if entered;
     *
     * + Whatever custom fields you have added to the sign-up flow =)
     *
     */
    $transient = WU_Signup()->get_transient(false);

  restore_current_blog();

  $replace_list['{{replace_with_client_email}}'] = $transient['user_email']; // Replace with the user's email
  $replace_list['{{another_thing_to_replace}}']  = 'Replaced Text';
  // ... You can add as many items as you want
 
  return $replace_list;
 
}, 10, 3);


This can be extremely useful when constructing about pages, contact pages, etc.

Did this answer your question?