Blob content in xf_option table

AndyB

Well-known member
Hello,

An admin I'm helping indicated my Register Email add-on was throwing an error during registration. What I found was the option_value field is different between his table and my test forum:

In his database the requireLocation is not present
pic001.webp

On my database the requireLocation is present
pic002.webp
 
Last edited:
Looks like the requireLocation is not going to be present unless that field in the Options page is selected at least once. So even if it's deselected it will remain in the option_value.
 
Th problem is in my Register Email add-on I have the following code:

PHP:
$requireLocation = XenForo_Application::get('options')->registrationSetup['requireLocation'];

So if the Require Location checkbox in the User Registration Options page has never been checked, the above PHP code throws an error due to the value not having been set yet. How can I prevent the server error? Do I need to do a database query directly on the xf_option table?
 
Last edited:
Use isset() or empty() to check if an array key has been set or if it is empty.
 
Like this?

PHP:
if (!empty(XenForo_Application::get('options')->registrationSetup['requireLocation']))
{
    $requireLocation = XenForo_Application::get('options')->registrationSetup['requireLocation'];
}
 
Last edited:
Top Bottom