Retriving all users with REST API not working

The problem may be pagination The API only returns 10 results per page, and needs follow up requests to fetch the rest. WP includes a HTTP header that tells you how many total results and the number of pages. It has a hard limit of 100 per page maximum, if you request 200, you will … Read more

Getting 401 from ajax using an application password

You should use cookie based authentication instead of basic auth. Delete the basic auth/application password authentication code. Follow the cookie authentication example that creates a post via the REST API from the REST API handbook: https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/#cookie-authentication Create a valid nonce for use in your AJAX requests in PHP wp_create_nonce( ‘wp_rest’ ) as the docs tell … Read more

Permission callback to check if user has application password

You’re conflating roles/capabilities and application passwords. This problem has nothing to do with application passwords. Application passwords are a way of authenticating who, that you are who you say you are. permission_callback isn’t interested in that though, just because you are indeed verified as you, does not mean you have permission to do what you’re … Read more

How to set a template with wp_insert_post

You can check this code I am able to work with this function cutom_function() { $new_page_id = wp_insert_post( array( ‘post_title’ => ‘PKB’, ‘post_type’ => ‘page’, ‘post_name’ => ‘pkb’, ‘comment_status’ => ‘closed’, ‘ping_status’ => ‘closed’, ‘post_content’ => ”, ‘post_status’ => ‘publish’, ‘post_author’ => get_user_by( ‘id’, 1 )->user_id, ‘menu_order’ => 0, // Assign page template ‘page_template’ => … Read more