Home » Php » Disable shortcode if status of value changes?

Disable shortcode if status of value changes?

Posted by: admin October 18, 2018 Leave a comment


Looking to do enable or disable shortcode in a function, depending on a value. For instance, if someone says purchases a license key to use some shortcode on their site, I’d like to have the shortcode become disabled if they license expires. Example function I’ve been working on below:

my_premium_shortcodes(); // Fires early in my php file

function my_premium_shortcodes(){
    $status     = get_option( 'key_status' );

    if( $status !== false && $status == 'valid' ) { 


    } else {



Any input on my approach or if the function should be handled in a separate way would be appreciated. As it stands, the shortcodes are working when everything is enabled, but stay enabled even after the ‘status’ changes to ‘invalid’.