• I am currently creating an update to a plugin that I wrote a long time ago. I am writing a new function that creates a new table in the database that will hold all the plugin’s settings. The old version stores all the settings in the wp_options table. I want to migrate settings over to the new table, but only the ones that have a value.

    For example the old plugin stored some options in wp_option table with no values. How do I idenify which of these options are “valueless” and which aren’t? So far I have…

    if(strlen(get_option($name))>0){
    /*Migrate options here */
    }

    However using strlen makes the plugin crash on activation. Is there another way to check if the option exist?

Viewing 1 replies (of 1 total)
  • I think this is what you want

    if( !get_option( $name ) ) {
    // no nothing here
    } else {
    //your migrate stuff here
    }

Viewing 1 replies (of 1 total)
  • The topic ‘How Do I Check If An Option Exist??’ is closed to new replies.