I want to be able to close or lock a topic if you are the author of the topic or an admin or moderator
We are planning these features in our next release.
<?php
if($row['user_level'] == 4) {
print('User is an admin');
}
In codoforum, you can do above like this:
$user = User::get();
if($user->rid == ROLE_ADMIN) {
print('User is an admin');
}
But, in codoforum, we normally do not use if statements based on user roles but we use permissions.
So, first create a permission:
$permission = new \CODOF\Permission\Permission();
$permission->add('lock topics', 'forum', array(
ROLE_USER, ROLE_MODERATOR, ROLE_ADMIN
));
After, you define a permission like this, it will automatically become available in the backend for all roles as well as for every category.
Then, you can simply do:
$user = User::get();
if($user->can('lock topics')) {
}
I'm pretty sure you can also do it with a "pin" or "sticky" feature as well right?
Codoforum already supports sticky feature.
&gt;I want to be able to close or lock a topic if you are the author of the topic or an admin or moderator
We are planning these features in our next release.
```
&lt;?php
if($row['user_level'] == 4) {
print('User is an admin');
}
```
In codoforum, you can do above like this:
```
$user = User::get();
if($user-&gt;rid == ROLE_ADMIN) {
print('User is an admin');
}
```
But, in codoforum, we normally do not use if statements based on user roles but we use permissions.
So, first create a permission:
```
$permission = new \CODOF\Permission\Permission();
$permission-&gt;add('lock topics', 'forum', array(
ROLE_USER, ROLE_MODERATOR, ROLE_ADMIN
));
//first param is permission name
//second is just a category name for permissions
//third is an array specifying the roles that will have permission set as GRANTED
```
After, you define a permission like this, it will automatically become available in the backend for all roles as well as for every category.
Then, you can simply do:
```
$user = User::get();
if($user-&gt;can('lock topics')) {
//let him lock them
}
```
&gt; I'm pretty sure you can also do it with a "pin" or "sticky" feature as well right?
Codoforum already supports sticky feature.
Necessity is the mother of all inventions!
edited Aug 10 '15 at 6:39 pm