简体   繁体   English

如何在JavaScript中获取Liferay用户的电子邮件地址?

[英]How to get Liferay user email address in JavaScript?

I can able to get themeDisplay object in JavaScript. 我可以在JavaScript中获取themeDisplay对象。

Refereed : https://web.liferay.com/web/pankaj.kathiriya/blog/-/blogs/usage-of-liferay-js-object 推荐人: https : //web.liferay.com/web/pankaj.kathiriya/blog/-/blogs/usage-of-liferay-js-object

$( document ).ready(function() {
  var userid=Liferay.ThemeDisplay.getUserId;
  alert(userid);
});

How to get User email Address ? 如何获得User email Address

Liferay JS utility's Liferay.ThemeDisplay or just themeDisplay does not implicitly contain user's email address. Liferay JS实用程序的Liferay.ThemeDisplay或仅themeDisplay不隐式包含用户的电子邮件地址。 It just exposes userId and userName while it doesn't have any getUser or User object in it. 它只公开userIduserName而其中没有任何getUserUser对象。

However, you can achieve that by overridding \\html\\common\\themes\\top_js.jspf using JSP hook. 但是,您可以通过使用JSP挂钩覆盖\\html\\common\\themes\\top_js.jspf来实现。 All you need to do is to add following lines below getUserName: function() { : 您需要做的就是在getUserName: function() {下面添加以下行getUserName: function() {

getUserEmailAddress: function() {
    <c:choose>
        <c:when test="<%= themeDisplay.isSignedIn() %>">
            return "<%= UnicodeFormatter.toString(user.getEmailAddress()) %>";
        </c:when>
        <c:otherwise>
            return "";
        </c:otherwise>
    </c:choose>
},

Then you will be able to get user's email address by either Liferay.ThemeDisplay.getUserEmailAddress(); 然后,您将可以通过Liferay.ThemeDisplay.getUserEmailAddress();获取用户的电子邮件地址Liferay.ThemeDisplay.getUserEmailAddress(); or themeDisplay.getUserEmailAddress(); themeDisplay.getUserEmailAddress(); .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM