Hide custom title when removed from a group

Martok

Well-known member
I am looking at setting up a promotion for the active members on my forums whereby they will be added to a group that will give them some additional privileges. One of these is for them to have a custom title. That's straightforward to set up, of course.

However, I would like to be able to remove members from this group in the future if they aren't as active, reverting them back to standard privileges. This would mean that they would no longer be able to have a custom title.

I've tested this and when a user is removed from the group, they can no longer change their custom title as the field is no longer visible to them in their personal details. However, the custom title still appears in their posts.

Is there a way to automatically revert the user's title back to the 'standard' ones I'm using for the rest of the members on the forums? I'd rather not have to manually delete their titles in order to do this.
 
If you were to change all instances of
Code:
{xen:helper userTitle, $user}
to
Code:
{xen:helper userTitle, $user, false}
if a user isn't in a particular group, it'll ignore their custom titles. Otherwise, the system seems to always respect custom titles.

You could also write a quick and dirty cron job to find any user who has a custom title and doesn't belong to the specific group to wipe it out of the database. For a cron, the following query will eradicate it, just change the user group with permissions in the last one:
Rich (BB code):
UPDATE`xf_user`SET`custom_title`=''WHERE`custom_title` != ''AND`secondary_group_ids`NOT LIKE '%5%'

Just change the red 5 to whatever the user group is.

However, both situations aren't pretty.
 
Last edited:
Thanks for this. :)

It's not a big issue really but it would be nice if there was an easy way to do this. Maybe I'll put it as a suggestion for a future version.
 
The problem with having custom titles wiped in the manner suggested above is the admin would never be able to set one manually.

Or even those users with the permission to set their own.
 
The problem with having custom titles wiped in the manner suggested above is the admin would never be able to set one manually.

Or even those users with the permission to set their own.

Mine takes into account not being in a specific group for the second one. But yeah, it does destroy custom ones set by an admin.
 
Top Bottom