The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
db query in during_user_creation - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23)
+--- Forum: UserSpice 4.4 (https://userspice.com/forums/forumdisplay.php?fid=27)
+--- Thread: db query in during_user_creation (/showthread.php?tid=1404)



db query in during_user_creation - LoveJailbreak4S - 03-29-2019

Hello,
at first, i love Userspice for so feature rich and easy understanding (after one week of reading and testing).
I changed the core _join.php file for my needs with a Dropdown to select with "typ" the new user is. My typs are "model", "videograph" and "fotograph".
now the chellange: i tried to edit the during_user_creation to do the following:
If the new user select the typ "model", give him automatically the permissionlevel "4" (4 is permissionlevel "model" i have created).
i tried an if-statement but i think this is really garbage (copied the ['typ'=>Input::get('typ')] code and match it with 'model')

Can you help me with this if-statement and db query?

Have a nice day


RE: db query in during_user_creation - mudmin - 03-29-2019

(03-29-2019, 07:45 AM)LoveJailbreak4S Wrote: Hello,
at first, i love Userspice for so feature rich and easy understanding (after one week of reading and testing).
I changed the core _join.php file for my needs with a Dropdown to select with "typ" the new user is. My typs are "model", "videograph" and "fotograph".
now the chellange: i tried to edit the during_user_creation to do the following:
If the new user select the typ "model", give him automatically the permissionlevel "4" (4 is permissionlevel "model" i have created).
i tried an if-statement but i think this is really garbage (copied the ['typ'=>Input::get('typ')] code and match it with 'model')

Can you help me with this if-statement and db query?

Have a nice day

I'm glad you're enjoying UserSpice! Just one thing on the _join.php, there is a file in usersc/scripts called additional_join_form_fields.php to let you put that extra dropdown box in without risking having your code broken during an update.

So I'm guessing that your typ dropdown has a value of model in there somewhere, if so, it would look like this in during_user_creation.php
if(Input::get('typ') == 'model'){
$fields = array(
'user_id' =>$theNewId,
'permission_id'=>4,
);
$db->insert('user_permission_matches',$fields);

I'm pretty sure that's it. If it's not, let me know.


RE: db query in during_user_creation - LoveJailbreak4S - 03-29-2019

(03-29-2019, 08:51 AM)mudmin Wrote:
(03-29-2019, 07:45 AM)LoveJailbreak4S Wrote: Hello,
at first, i love Userspice for so feature rich and easy understanding (after one week of reading and testing).
I changed the core _join.php file for my needs with a Dropdown to select with "typ" the new user is. My typs are "model", "videograph" and "fotograph".
now the chellange: i tried to edit the during_user_creation to do the following:
If the new user select the typ "model", give him automatically the permissionlevel "4" (4 is permissionlevel "model" i have created).
i tried an if-statement but i think this is really garbage (copied the ['typ'=>Input::get('typ')] code and match it with 'model')

Can you help me with this if-statement and db query?

Have a nice day

I'm glad you're enjoying UserSpice! Just one thing on the _join.php, there is a file in usersc/scripts called additional_join_form_fields.php to let you put that extra dropdown box in without risking having your code broken during an update.

So I'm guessing that your typ dropdown has a value of model in there somewhere, if so, it would look like this in during_user_creation.php
if(Input::get('typ') == 'model'){
$fields = array(
'user_id' =>$theNewId,
'permission_id'=>4,
);
$db->insert('user_permission_matches',$fields);

I'm pretty sure that's it. If it's not, let me know.

THANK YOU mudmin! It's working after i added "}" at the end of your statement Wink
Thank you for the fast and working response.
The reason why i edit the Core files is, that i can use my Bootstrap 4 design and use Userspice as the strong background.


And thank you again for Userspice, it's so nice to use and develop if you understand the base of Userspice.
Have a nice day.


RE: db query in during_user_creation - mudmin - 03-29-2019

Ahh. I didn't have my code editor with me. I figured I would miss something. One of a great things about the software that you can pretty much use it however you want. It is possible to use bootstrap for what's the templates, but you don't have to do it that way.