0

I have added custom setting options page under WordPress settings and those are working perfectly. I have tested their values also. But when I am using those values inside function file within add_action init hook to perform something on form submission, those values are returning as null. Everything is working except those values return as null. A few examples will really help me! Thanks in advance :)

    add_action('init', 'myFunc');
    function myFunc(){
        $myoptions   = get_option( 'custom_option' );
        $trueorfalse = $myoptions['my_swicth'];
        $alertemail  = $myoptions['alert_email']; // both working outside
        if( 1 == $trueorfalse && '[email protected]' == $alertemail ){
            //do something
        }
    }
1
  • Please let me know if my question is not valid! or anyone need more explanation. Commented Jul 12, 2015 at 4:32

1 Answer 1

0

I found the answer. Problem was I was retrieving those setting option values outside the if statement if(isset($_POST['formvalue'])){ } and using them inside it. For that reason values were actually not pulled from database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.