Forum breadcrumbs – You are here:Asgaros Support ForumSupportAbout User Permissions
Please or Register to create posts and topics.

About User Permissions

PreviousPage 2 of 2

I made a code to create a registration screen.
What code should I add to give moderator privileges to this?

add_action( 'template_redirect', 'entry_init' );
 
function entry_init() {
    if ( ! is_page( 'entry' ) ) {
        return;
    }
 
    if (isset($_POST['nickname'])) {
        $user = array();
        $user['user_login'] = 'user' . date( 'YmdHis' ) .  sprintf( '%03d', mt_rand( 0,999 ) );
        $user['user_pass'] = $_POST['user_pass'];
        $user['user_email'] = $_POST['user_email'];
        $user['nickname'] = $_POST['nickname'];
        $user['display_name'] = $_POST['nickname'];
        $user['role'] = 'Subscriber';
        $inserted = wp_insert_user($user);
    }
}

 

Quote from Asgaros on January 11, 2019, 3:27 pm

Hello @pal

Currently every member who has access to a specific category can also create topics or posts inside it. However there are a few restrictions:

  • If a topic is closed, only moderators/administrators can create posts inside it.
  • If a forum is closed, only moderators/administrators can create topics inside it. Normal users can still create posts in those topics as long as the topics are not closed as well.

If you need the normal user-role and another user-role which has read-only access only, there is currently only one workaround: You need to ban the users who should not be able to create topics and/or posts. Banned users can still access topics normally like a guest (based on your access-permission settings for categories) but are not able to create topics or posts.

Hi, just one question: Where can I close the forum? Because I have the same issue. We have 3 moderators, and about 10 users who should only be able to read in certain forums. If I get you right, to realize “Read-Only” it is required to both close the forum and the topic?

Thanks a lot!

Max

You can close the forum from the editing screen of the forum.

Hello @max_b

Yes, you have to close the forum and the topics.

@pal TheĀ wp_insert_user() function should return the ID of the inserted user. This ID can be used to add the moderator-role with the code-example I posted before.

max_b has reacted to this post.
max_b
If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Thank you very much.
I’ll try!

Quote from pal on January 14, 2019, 12:41 pm

You can close the forum from the editing screen of the forum.

Thank you @pal and @asgaros. This works fine for me!

Best regards, Max

PreviousPage 2 of 2