phpBB

Development Discussion Board

phpBB's testing ground of bleeding edge code
Advanced search

[API] make user X moderator on forum Y

Discuss general development subjects that are not specific to a particular version like the versioning control system we use or other infrastructure.

[API] make user X moderator on forum Y

Postby matteoZC » Fri Jun 01, 2012 7:37 am

Hello!
I'm new to phpBB.

We're developing a web app which will interact with a phpBB forum.
When a certain kind of users register on our web app, we want to give them a phpBB account with the same credentials, a forum and the moderator role on that.

Thanks to your API, I can create a new user X, I can create a new forum Y, but i don't know how to make X a moderator on Y.

I've given a look at the wiki here at area51 but i didn't get how to do it.

Can you help me, please? (I hope this is the right forum section to post)
matteoZC
Registered User
 
Posts: 2
Joined: Fri Jun 01, 2012 7:24 am

Re: [API] make user X moderator on forum Y

Postby imkingdavid » Fri Jun 01, 2012 12:46 pm

Actually, a better place to ask this would be on phpBB.com's Community board in the MOD Writers' Discussion forum. This board is more for discussion about actual phpBB development, rather than custom 3rd party app development.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.
User avatar
imkingdavid
Development Team
Development Team
 
Posts: 905
Joined: Thu Jul 30, 2009 12:06 pm

Re: [API] make user X moderator on forum Y

Postby naderman » Fri Jun 01, 2012 12:59 pm

This points out that we really need area51.phpbb.com/phpBB/viewtopic.php?f=108&t=42731 though.
www.naderman.de
Move your forum to Forumatic - we'll take care of maintenance & spam
User avatar
naderman
Development Team Leader
Development Team Leader
 
Posts: 1650
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany

Re: [API] make user X moderator on forum Y

Postby matteoZC » Fri Jun 01, 2012 2:04 pm

I've managed to solve the problem with something like
Code: Select all
define('IN_PHPBB', true);
define('PHPBB_ROOT_PAHT', "/the/forum/installation/path/");
define('PHPEX', "php");
define('ROLE_MOD_STANDARD', 11);
define('PHPBB_ACL_USERS','phpbb_acl_users');

   function makeModerator($userId, $forumId) {
      global $phpbb_root_path;
      global $phpEx;
      global $db;
      global $config;
      global $user;
      global $auth;
      global $cache;
      global $template;

      $phpbb_root_path = PHPBB_ROOT_PAHT;
      $phpEx = PHPEX;

      require_once($phpbb_root_path . 'config.' . $phpEx);
      require_once($phpbb_root_path . 'common.' . $phpEx);
      
      $query = "INSERT INTO ".PHPBB_ACL_USERS." (user_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ('$userId', '$forumId', '0', '".ROLE_MOD_STANDARD."', '0')";
      $db->sql_query($query);
   }


...but i think it's an extremely low level solution, which i've reached looking at the differences on the db after i've added a new moderator.

Yes, a phpBB API would be great!!
matteoZC
Registered User
 
Posts: 2
Joined: Fri Jun 01, 2012 7:24 am

Re: [API] make user X moderator on forum Y

Postby naderman » Fri Jun 01, 2012 3:59 pm

Well you probably want to have a group for moderators which has those permissions, and then just add the user to a group, rather than assign permissions to the user himself.
www.naderman.de
Move your forum to Forumatic - we'll take care of maintenance & spam
User avatar
naderman
Development Team Leader
Development Team Leader
 
Posts: 1650
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany


Return to General Development Discussion

Who is online

Users browsing this forum: No registered users and 5 guests