Ning Developer Network

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.

Tags: grant, role, roles, xn_profile::grantrole

Share Twitter

Replies to This Discussion

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.

Cheers,
Rob
thanks rob, i'll give that a try. I kind of gave up on it, so hopefully this will work.
I would love to get more details on that, however I don't think role code has to be numeric as per their documentation:
http://developer.ning.com/main/docs/XN?../../d1/d10/class_x_n___pro...

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

RSS

© 2010   Created by Ning Developer Admin

Badges  |  Report an Issue  |  Privacy  |  Terms of Service