Getting a fatal error from wpforms-lite/includes/fields/class-name.php that says “Cannot access offset of type string on string”?
In plain English, WPForms expected the Name field data to be an array like ['first'] and ['last'], but it got a plain string instead. That mismatch is what PHP is complaining about.
This is usually caused by:
• A corrupted or outdated Name field on a specific form
• Custom code or a snippet hooking into WPForms and changing the Name data
• A plugin or theme conflict that filters form values in a bad way
Below is how to get your site back online, then narrow down which of those is actually happening on your install.
WPForms Lite is throwing “Cannot access offset of type string on string” in includes/fields/class-name.php (Name field). How do I fix this?
Short answer: this error means WPForms tried to treat your Name field value like an array, but PHP says it is just a string. So something in your form setup or custom code is changing the data shape.
Let us walk through how to make the site stable, then track down which thing is doing that.
If this fatal error is taking down the whole site, stabilize things first.
wp-content/plugins/.wpforms-lite folder to something like wpforms-lite-disabled.WordPress will stop loading WPForms, and the site should come back.
Once we have identified and fixed the cause, you can rename the folder back to wpforms-lite and reactivate the plugin in the dashboard.
The key part of the message is:
TypeError: Cannot access offset of type string on string
This is PHP saying:
“You tried to do $something['first'] but $something is a text string, not an array.”
Inside WPForms, the Name field expects an array like:
$field_submit = [
'first' => 'John',
'last' => 'Doe',
'middle' => '',
];
If something turns that into a plain string such as "John Doe", the Name field code in class-name.php still tries to do $field_submit['first']. On PHP 8 and up, that turns from a warning into a fatal error.
First, make sure you are not fighting a bug that was already fixed.
Then check your PHP version in Tools → Site Health → Info → Server.
Retry the form or the page that previously crashed.
You want to know if this is global or limited to one form.
wp-config.php (if not already):define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
wp-content/debug.log and look for the line with class-name.php.Often the log will also show the form ID or field ID near the stack trace. Even if it does not, you now know that the crash happens on a specific page.
There are cases in the WPForms support forums where notices and warnings from class-name.php went away just by recreating a field, which suggests the stored field settings can get into a bad shape.
On the affected form:
If the fatal error disappears after rebuilding the Name field, the problem was likely a corrupt or outdated field configuration. You can stop here and keep an eye on your logs.
If the error persists, move on.
WPForms has a lot of developer hooks. It is common to see custom snippets that read or change the Name field, for example to block certain names or tweak validation.
Those snippets sometimes assume the data is always an array and do not check the type. On PHP 8 that can blow up with the same error you are seeing.
In your theme or code snippets plugin:
functions.php and any “code snippet” plugins you use.wpforms_ and especially:
wpforms_process_validate_namewpforms_process_validate_ (any field type)wpforms_processwpforms_field_properties_nameIf you find a function that works with the Name field, check how it handles the submitted value.
Anything like this is fine:
function mysite_name_validation( $field_id, $field_submit, $form_data ) {
// Make sure the value is the expected array shape
if ( ! is_array( $field_submit ) ) {
return;
}
// Safe to access subfields now
$first = isset( $field_submit['first'] ) ? $field_submit['first'] : '';
$last = isset( $field_submit['last'] ) ? $field_submit['last'] : '';
// Your custom logic here
}
add_action( 'wpforms_process_validate_name', 'mysite_name_validation', 10, 3 );
But if you see code that does this with no type check:
$submitted_name = $field_submit['first'] . ' ' . $field_submit['last'];
and there is any chance $field_submit might be a string, PHP 8 will throw “Cannot access offset of type string on string”.
Temporarily comment out that snippet or wrap it in an is_array() check as shown above. Then test the form again.
is_array() and isset().If you do not have custom code or the checks above look fine, the next most likely cause is another plugin or theme filtering $_POST or form data in a way that flattens the Name field into a string.
If the error disappeared during the conflict test:
Once you identify that plugin or the theme:
$_POST data.class-name.php.At this point you have:
If none of that stops the fatal error, this is likely something very specific to your installation.
Open a ticket with WPForms (or post in their WordPress.org forum if you are on Lite) and include:
Cannot access offset of type string on string and class-name.php.This gives them enough information to reproduce or point out a known edge case.
You are in good shape when:
debug.log no longer shows new entries from includes/fields/class-name.php.is_array() checks.Scroll down and click Continue Chat. Tell me:
I can help you walk through the log and narrow it down further.
Scroll down to the contact form below. Enter your name, email, and WordPress needs. Atiba will get back to you as soon as possible.
WP Assistant is a free tool created by Atiba Software, a WordPress design and development company located in Nashville, TN. If you need more personalized WordPress assistance let us know, and we’ll get back to you ASAP!