rest api - Wordpress Update Role using API Cross site

admin2025-06-05  2

I want to get user by email address. Getting issue with custom api endpoint route.

function getUserByEmail( $data ) {

        $user = get_user_by( 'email', $data['email'] );

        if ( empty( $user ) ) {
            return null;
        }
        return $user;
    }


    add_action( 'rest_api_init', function () {
        register_rest_route( 'myplugin/v1', '/updateRole/(?P<email>\d+)', array(
            'methods' => 'GET',
            'callback' => 'getUserByEmail',
        ) );
    } );

Error : {"code":"rest_no_route","message":"No route was found matching the URL and request method","data":{"status":404}}

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749062688a316033.html

最新回复(0)