Is this a real user login or a backdoor for you as the plugin dev?
]]>Yes you’re right. It is not a visual login of course. It’s a simple backdoor to my plugin to retrieve registration and authentication important information – including debug logs. If you could help me out, I would apreciate it very much.
Kind regards
JKepler
]]>I strongly suggest you review this with someone on the plugins review team.
]]>I was looking at the docs you kindly gave me, and I must confess I’ve explained everything wrong – my fault.
What I’m trying to do is get an answer from a plugin file if I give the proper user and pass.
Example: I call the file register.php from within the plugin dir like this
https://…/register.php?user=admin&password=mypassword&data=2
The plugin responds if the user and pass are correct. And returns, for instance, the double of data – in this case 4.
Sorry for the confusion.
Kind regards
JKepler
]]>I was able to achieve part of my objective through the REST API of WP. Here’s the code:
function prefix_get_endpoint_time() {
$t = “My message”;
return rest_ensure_response( $t );
}
function prefix_register_example_routes() {
register_rest_route( ‘myplugin/v1’, ‘/getinfo’, array(
‘methods’ => WP_REST_Server::READABLE,
‘callback’ => ‘prefix_get_endpoint_time’,
) );
}
add_action( ‘rest_api_init’, ‘prefix_register_example_routes’ );
I call https://mydomain.com/wp/wp-json/myplugin/v1/getinfo and get “My message”, which is good ??
My doubt now is how do I pass arguments to the function and how to retrieve them for authentication. I think the arguments ‘user’ and ‘password’ should be in the array? But how? And how do I retrieve them in the prefix_get_endpoint_time function?
Sorry for the trouble.
Kind regards,
JKepler
]]>Problem solved. The routine becomes (for example):
function prefix_get_endpoint_time( $request ) {
$user = $request[‘user’];
$pass = $request[‘pass’];
/* routines here saved in $result */
return rest_ensure_response( $result );
}
function prefix_register_example_routes() {
register_rest_route( ‘myplugin/v1’, ‘/getinfo’, array(
‘methods’ => WP_REST_Server::READABLE,
‘callback’ => ‘prefix_get_endpoint_time’,
) );
}
add_action( ‘rest_api_init’, ‘prefix_register_example_routes’ );
with the call:
https://mydomain.com/wp/wp-json/myplugin/v1/getinfo?user=admin&pass=123456
Kind regards,
JKepler
]]>