Is there a way to add new users in the background?

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
Carzboy
Registered User
Posts: 3
Joined: Tue Sep 14, 2021 7:30 pm

Is there a way to add new users in the background?

Post by Carzboy »

Hi all,

I have this website where i already have my user tables and my login procedures.
But is it possible when new users register on my website it also creates a user for the phpbb forum?

Hope to hear from you guys.

Kind regards
Last edited by thecoalman on Fri Sep 17, 2021 3:24 am, edited 1 time in total.
Reason: Moved to custom coding.
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Is there a way to add new users in the background?

Post by david63 »

It is possible but not without some form of connection. Without knowing how you currently handle user registrations and how your website is set up it is impossible to give you any kind of answer on how to achieve this
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 52768
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: Is there a way to add new users in the background?

Post by stevemaury »

phpBB supporls LDAP. This explains more - https://connect2id.com/products/ldapauth/auth-explained
I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 5885
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: Is there a way to add new users in the background?

Post by thecoalman »

Haven't used it but AFAIK you can do it with phpBB's CLI.

https://area51.phpbb.com/docs/dev/3.3.x ... arted.html
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
Carzboy
Registered User
Posts: 3
Joined: Tue Sep 14, 2021 7:30 pm

Re: Is there a way to add new users in the background?

Post by Carzboy »

Thanks for all the help so far!

I use this and i got a record in the database added so far im cool but after the insert the forum was not accesable anymore.
When i got that sorted out i'll let you know.

Code: Select all

<?php

/*$user_row = array(
        'username'          => "NAME",
        'user_password'     => "PASSWORD",
        'user_email'        => "EMAIL",
        'group_id'          => 2,
        'user_type'         => 0,
    );*/
  function NewUser($user_row) 
  {
    global $phpbb_container;
    global $phpbb_dispatcher;
    global $db, $config;
    global $table_prefix;
    define('IN_PHPBB', true);
    global $phpbb_root_path;
    global $phpEx;
    $phpbb_root_path = './forum/';
    $phpEx = 'php';
    
    include($phpbb_root_path . 'common.php');
    include($phpbb_root_path . 'includes/functions_user.php');
    
		return user_add($user_row);
	}



?>
Carzboy
Registered User
Posts: 3
Joined: Tue Sep 14, 2021 7:30 pm

Re: Is there a way to add new users in the background?

Post by Carzboy »

Well i got it work.
I can use the functions from phpbb to create a new user and validate his password.

When someone signs up at my website it automatically makes an account in PhpBB as well.
I use the same password complexity from PhpBB for my own website so in general it should work when a user logins on my website it also logs in on the phpbb forum.

I use this code;

Code: Select all

<?php
function HashPassword($Password) 
{
    global $phpbb_container;
    global $phpbb_dispatcher;
    global $db, $config;
    global $table_prefix;
    define('IN_PHPBB', true);
    global $phpbb_root_path;
    global $phpEx;
    $phpbb_root_path = './forum/';
    $phpEx = 'php';
    
    include($phpbb_root_path . 'common.php');
    include($phpbb_root_path . 'includes/functions_user.php');
    
    $passwords_manager = $phpbb_container->get('passwords.manager');
    
return $passwords_manager->hash($Password);
}

function NewUser($UserName, $Password, $Email) 
{
    global $phpbb_container;
    global $phpbb_dispatcher;
    global $db, $config;
    global $table_prefix;
    define('IN_PHPBB', true);
    global $phpbb_root_path;
    global $phpEx;
    $phpbb_root_path = './forum/';
    $phpEx = 'php';
    
    include($phpbb_root_path . 'common.php');
    include($phpbb_root_path . 'includes/functions_user.php');
    
    $passwords_manager = $phpbb_container->get('passwords.manager');
    
    $user_row = array(
        'username'          => $UserName,
        'user_password'     => $passwords_manager->hash($Password),
        'user_email'        => $Email,
        'group_id'          => 2,
        'user_type'         => 0,
    );
    
    //user_add from 'includes/functions_user.php' which returns userid.
return user_add($user_row);
}
?>
Post Reply

Return to “phpBB Custom Coding”