I will briefly clarify the task - I am writing a small plugin for authorization, registration and other user interactions with the site. In one part of the code that is responsible for the user's login, I want to perform verification actions in a separate file in the same directory. In the form of an action I address to the desired file

<form name="loginform" id="loginform" action="'. plugins_url('check_data.php', __FILE__) .'" method="post"> 

The check_data.php file is included in the plug-in file being initialized, but WordPress functions do not work in this file. I get an error of such a plan. Fatal error: Call to undefined function wp_signon() in

  • 2
    You need to add require_once ($ _SERVER ['DOCUMENT_ROOT']. '/Wp-load.php'); - Pavel Mucha

1 answer 1

You need to initialize the WordPress core. If your check_data.php file is located on the path /wp-content/plugins/my-plugin/check_data.php, then you should insert the line

 /** Load WordPress Bootstrap */ require_once dirname( dirname (dirname( dirname( __FILE__ ) ) ) ) . '/wp-load.php'; 
  • It worked, but again the difficulty)) It is necessary to redirect, depending on the role, to different URLs, the whoIs method is responsible for this, and it checks the current_user_can ('administrator') function, etc. But this function does not work, what could be the reason? - Pavel Mucha
  • Without seeing the code, I can not understand the question. Ask a separate question, describe everything in it. - KAGG Design