What Are Functions?

In the PRO addon, a Function is a small PHP snippet that receives a field value and returns a transformed version of it. You can assign functions to fields in the Import, Export, and Content Updater workflows.

For example, a function might:


Function Anatomy

Every function receives two arguments and must return the transformed value:

function transform( $value, $row ) {
    // $value — the current field value
    // $row   — associative array of all fields in the current row
    return strtolower( trim( $value ) );
}
VariableDescription
$value The current value of the field this function is assigned to.
$row An associative array containing all field values for the current row (useful when you need to build a value from multiple fields).
return The function must return the final value. If nothing is returned, the original value is used.

Managing Functions

Creating a New Function

Navigate to WP Import Export by RockStarLab → Functions and click Add New Function.

Functions Library
The Functions Library showing saved functions

The function editor contains the following fields and controls:

Field / ControlDescription
Function Name A descriptive label used to identify the function in dropdowns across import, export, and bulk update workflows (e.g., "Format Date to Y-m-d").
Description Optional notes about what the function does and when to use it.
AI Generator Click this button to open the AI prompt panel. Describe the transformation you need in plain English and the AI will generate the PHP code for you automatically.
PHP Code The built-in code editor where you write or paste the function body. Supports syntax highlighting.
Test Function Enter a sample value in the Enter test value field and click Test to run the function against it. The result is shown instantly — no data is affected.
Save Saves the function to the library. Once saved, it becomes available in all field mapping dropdowns immediately.
Function code editor
The built-in code editor with syntax highlighting

Saving & Reusing

Once saved, the function appears in the field mapping dropdowns across all import, export, and bulk update operations. Functions are global — they can be used in any job.


AI Function Generator

Not comfortable writing PHP? Use the Generate with AI button to describe what you need in plain English and let the AI write the function for you.

AI Function Generator
Describing a transformation in plain English — the AI writes the code
AI Function Generator
Describing a transformation in plain English — the AI writes the code

Example prompts:

â„šī¸ OpenAI API Required
The AI Function Generator uses the OpenAI API. Configure your API key in Plugin Options before using this feature.

Built-in Snippets Library

The plugin includes 50+ ready-to-use function snippets organised by category. Browse the Snippets tab on the Functions screen to find pre-built transformations you can use directly or customise.

The built-in Functions Snippets Library
The built-in Functions Snippets Library

Snippet Categories


Security

Function code is executed in a sandboxed environment. A whitelist/blacklist system controls which PHP functions and classes are permitted, preventing access to dangerous system calls such as exec(), shell_exec(), system(), file system writes, and network requests.

âš ī¸ Functions Run PHP on Your Server
Only create and run functions that you trust. Even with sandboxing, ensure that code written by the AI Generator is reviewed before use in production.
📚

Check our blog for more tutorials

Explore practical guides, workflow ideas, and step-by-step tutorials for importing, exporting, syncing, and managing WordPress content.

Visit the Blog →