Using the Search and Replace API on site duplication

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.

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

Was this article helpful?

Related Articles


  1. fitpromatt

    @admin This is a very cool feature! I have the use case where I want to pre-fill my Divi Contact forms with the admin email upon new site creation.
    Am I understanding correctly that I can use the WP Ultimo -> Settings -> Search & Replace -> Add new Pair fields to add this, or will I still have to edit functions.php?
    Example: Can I just add a new pair in the UI fields?
    Search: {{replace_with_client_email}}
    Replace: $current_user->user_email

    1. Arindo Duque

      Hey there. Unfortunately, the UI does not support dynamic values yet… I’m working to get it to work for future releases, but for now you’ll need to edit the functions.php using the examples on this tutorial.

  2. Daniel

    Does this search and replace API work when duplicating template sites that have pages built using elementor??

    1. Arindo Duque

      Yes, you should be able to place the placeholders inside the Elementor templates and WP Ultimo will replace them automatically on site duplication =)

  3. taropaa

    Can I use {{Website Name}} or something similar as tags, even if the website is being created through the wp-admin (by a superadmin using a template)?

Leave A Comment?