Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Access plugin file

Discussion in 'Misc WordPress Requests' started by jkepler, Dec 13, 2017.

  1. jkepler


    Reply To: Access plugin file, by jkepler

    Hi again

    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 http://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,


    Reply To: Access plugin file

Share This Page

Monarch Social Sharing Plugin