V5: How to add new service to users-permissions plugin?

System Information
  • Strapi Version: 5.5.1

Can anyone please help me with adding custom services to the users-permissions plugin?
By far I’ve done this much.

// src/extensions/users-permissions/strapi-server.js

module.exports = (plugin) => {
  plugin.services["getProfileId"] = async (id) => {
    let userDocumentId;
    let profileId;
    let kind;

    if (id == "me") userDocumentId = strapi.state.user.documentId;
    else userDocumentId = id;

    const user = await strapi
      .documents("plugin::users-permissions.user")
      .findOne({
        documentId: userDocumentId,
        populate: {
          role: {
            fields: ["type"],
          },
          candidateProfile: {
            fields: ["documentId"],
          },
          recruiterProfile: {
            fields: ["documentId"],
          },
        },
      });

    if (user.role.type == "candidate") {
      profileId = user.candidateProfile.documentId;
      kind = "candidate";
    } else if (user.role.type == "recruiter") {
      profileId = user.recruiterProfile.documentId;
      kind = "recruiter";
    }

    return { profileId, kind };
  };

  return plugin;
};

And this is how I’m trying to call the service. But it’s not working. It says that the service getProfileId doesn’t exist.

// src/api/candidate-profile/controllers/candidate-profile.js

findOne: async (ctx, next) => {
      try {
        const { id } = ctx.params;

        let userDocumentId;
        if (id == "me") userDocumentId = ctx.state.user.documentId;
        else userDocumentId = id;

        const res = await strapi
          .service("plugin::users-permissions.user")
          .getProfileId(userDocumentId);

        console.log(res);
        return res;
      } catch (error) {
        ctx.internalServerError(error);
      }
    },