• Hello!

    I have successfully installed wordpress on my local machine’s xampp server and have several users added to a site I have created.

    I am attempting to use an outside application, Postman, to send http requests to my local wordpress instance. I have refered to the REST API handbook on how to send GET, POST, DELETE, etc. requests to my wordpress site.

    I am successful in submitting GET and POST requests, in which I have been able to view, create, and update user accounts. However, when sending DELETE requests: I continually receive the same error message:

    
    {
        "code": "rest_cannot_delete",
        "message": "The user cannot be deleted.",
        "data": {
            "status": 501
        }
    }
    

    The url I am using is:
    http://localhost/wordpress/creed-thoughts/wp-json/wp/v2/users/6?reassign=4&force=true

    The user being deleted is a “subscriber” and has an id of 6. This user’s data is being reassigned to another user who also has “subscriber” access with an id of 4.

    I have used this url (and modified it accordingly) for my GET and POST requests and have succeeded in viewing, creating, and updating users. I have played around with the url in attempting to delete different users and reassigning the data to other users with other credentials (such as “editor”, “contributor”, “super administrator”) and still received the same error message listed above.

    Am I missing something in my url when attempting to delete a user? What does the error message really mean??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Did you install WP multisite?

    wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php:734

    Thread Starter jbw14a

    (@jbw14a)

    Thank you so much for your response and reference to the documentation!

    Yes I have WP multisite enabled on my wordpress instance and, according to the class-wp-rest-users-controller php file, it is not possible to delete users in multisite.

    Are you aware of an alternative to deleting users, such as deactivating user accounts or is the act ridding users strictly impossible in WP multisite?

    You are welcome.

    I don’t know how to do it using rest-api

    Alternative solution is to code a function in WP with wp_delete_user function. Then you can call this function with admin-ajax

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Deleting wp users through Postman’ is closed to new replies.