Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call to undefined function add_options_page()

Tags:

wordpress

I developed the plugin for my wordpress project. I successfully tested it on my local xampp server with 5.3 php. Then I uploaded my project to the web hosting with php 5.2. First trouble which with I faced off was unsupporting anonymous functions in php 5.2. No issue, I redeclared all functions with names. But then I got error Call to undefined function add_options_page(), which I counldn't explain. Plz help me guys with your advices

My part of code:

function mainPage(){
        ///some code
        }

function mainPage2(){

    add_options_page('Submissions of MAIN page contact form', 'Submissions of MAIN page contact form', 'manage_options','ea_submissions2', mainPage());

    }
add_action('admin_menu',mainPage2());

I think something wrong with my funcitons, look through it please. There is no issue with php 5.2 as I thought, this part of code also doesn't work with php 5.3! Something wrong with my code

like image 601
Zheka Avatar asked Feb 16 '23 13:02

Zheka


1 Answers

I had a similar problem, turns out I was running a function too early:

Use admin_init hook instead of init

Hopefully that helps someone out :D

like image 70
Tarei SuperChur King Avatar answered Feb 23 '23 00:02

Tarei SuperChur King