Forum Replies Created

Viewing 6 replies - 16 through 21 (of 21 total)
  • Thread Starter jkepler

    (@jkepler)

    Hi

    Thanks for the help and…honesty.

    Kind regards,

    Kepler

    Thread Starter jkepler

    (@jkepler)

    Hi

    Yes, it is the best way. So I’ll create an end point with my own credentials. Just a question if I may: inside that endpoint, is it enougn then to place

    $user_id = wp_create_user( $username, $password, $email_address );
      wp_update_user(
        array(
          'ID'          =>    $user_id,
          'nickname'    =>    $username
        )
      );

    Must the user have and ID and both a username and nickname defined in wp_update_user? And I assume that the endpoint recognizes all these commands…

    Sorry for the trouble.

    Kind regards

    JKepler

    Forum: Fixing WordPress
    In reply to: Access plugin file
    Thread Starter jkepler

    (@jkepler)

    Hi again

    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

    Forum: Fixing WordPress
    In reply to: Access plugin file
    Thread Starter jkepler

    (@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 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

    Forum: Fixing WordPress
    In reply to: Access plugin file
    Thread Starter jkepler

    (@jkepler)

    Hi,

    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

    • This reply was modified 6 years, 11 months ago by jkepler.
    Forum: Fixing WordPress
    In reply to: Access plugin file
    Thread Starter jkepler

    (@jkepler)

    Hi Steve

    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

Viewing 6 replies - 16 through 21 (of 21 total)