I've been having trouble with XN_Profile::grantRole. Basically I want to assign a user a role and retrieve that when i need it.
This is my code:
$profile = XN_Profile::current();
XN_Profile::grantRole($profile->screenName, 'myRoleHere');
This returns and error in the error log saying:
#0 /php/includes/XN/XN/Profile.php(573): XN_Exception::reformat('Failed grant ro...', Object(XN_Exception))
Does the role I'm granting have to be already made? If so where do I create a role? Doesn't seem to have a function in the documentation to create roles.
What with this post being over a month and a half ago, I imagine you've already found the answer to your question - but I think the issue is that 'myRoleHere' has to be a numeric, and you're putting a string there.
I'm not 100% on that, as I'm just pouring over the documentation myself now, and I'm inexperienced enough to not know what everything is that I'm looking at, but I think that's it.
static XN_Profile::grantRole ( $ screenName,
$ roleCode
)
[static]
Static method to grant a role to a user.
Throws an XN_Exception if an error occurred.
Parameters:
$screenName string|XN_Profile screenName or XN_Profile object $roleCode string