Support Forum

Question regarding sp_add_membership()

RY Ryan
Ryan
Member

Hey,

I already use sp_add_membership and sp_remove_membership but I can’t find anywhere a function to do the same thing but by name of the forum group ie “Members” instead of by ID, for example the number 1… 

Also, I can’t even find where you’d find the id for the membership, I usually have to do it by the database.

Any idea?

3 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

I already use sp_add_membership and sp_remove_membership but I can’t find anywhere a function to do the same thing but by name of the forum group ie “Members” instead of by ID, for example the number 1…  

When you say ‘forum group’ you are referring to a User Group – correct? If you want a user group ID then you can get it on the Manage User Groups listing. It is over on the left.

RY Ryan
Ryan
Member

Hey,

Yeah, I am on about the user group. It would be good if the sp_add_membership function supported both integers (user group ids) & text (user group names) or is there an easy way to convert the user group name into a user group ID?

MP Mr Papa
Mr Papa
Member

well, as @yellow-swordfish says, you can get the ID for the usergroup name on the forum – usergroup – mange usergroups admin panel…

or you can do a query yourself to get the usergroup id from the name… something like (untested):

$usergroupname = 'xxxxxx';
$id = spdb_table(SFUSERGROUPS, "usergroup_name='$usergroupname'", 'usergroup_id');

just change xxxxxx to your name…