This project has moved and is read-only. For the latest updates, please go here.

SPServices.SPGetCurrentUser Not pulling user

Jan 12, 2016 at 7:21 PM
I'm trying to use SPServices to pull the usergroup of the logged in user but it doesn't appear to be grabbing the user. Here's the code I'm using.
<script languague="javascript" type="text/javascript" src="/Style%20Library/JS/jquery-1.9.1.min.js"></script>
<script languague="javascript" type="text/javascript" language="javascript" src="/Style%20Library/JS/jquery.SPServices-2014.02.min.js"></script>
<script languague="javascript" type="text/javascript">
$(document).ready(function() {
  operation: "GetGroupCollectionFromUser",
  userLoginName: $().SPServices.SPGetCurrentUser(),
  async: false,
  completefunc: function(xData, Status) {
  var xml = xData.responseXML.xml;
   //If the current User does belong to the group "Business Card Logo Group"
    if ('Business Card Logo Group') == -1)
          alert("No, User Doesn't Exists!");                   
          //$('"Logo Selection")').parent().hide();
          $('nobr:contains("Logo Selection")').closest('tr').hide();
Jan 13, 2016 at 5:44 PM
Edited Jan 13, 2016 at 5:47 PM
Are you getting any errors? Have you stepped through the code to see if xml is defined?

If you're on Office365 or using claims, $().SPServices.SPGetCurrentUser() will return "i:0#.f|membership|". The SOAP services don't understand claims.

Jan 13, 2016 at 9:29 PM
No error messages. Just nothing happens. if I put in an alert
I get nothing. But if I put in
It does successfully return the site name. This is on prem 2013.
Jan 13, 2016 at 11:33 PM
$().SPServices.SPGetCurrentUser() should return the user's account by default - the Account field from /_layouts/userdisp.aspx?force=true. That page shows the values in the User Information list in the Site Collection.

Again, if you are using claims, that value will not work for GetGroupCollectionFromUser.