It looks like you're new here. If you want to get involved, click one of these buttons!
Using version 1.4.2. Been a while since I've done any PHP stuff and used FuelCMS and CodeIgniter so I may be trying something I shouldn't. Here goes.
Ion_Auth creates a table named 'users' which conflicts with the fuel_users module so I created a simple module name 'Members_module' but referenced the 'users' table.
ISSUE 1: Ion_Auth has an 'active' field in the 'users' table but it uses 1/0 instead of 'yes','no'. Is there a way to defeat the automatic addition to the query that looks for active = 'yes'? I tried find_one_by_id($user_id) and just the basic find_one() with a 'where' query but it still adds the check for active = 'yes'.
As a temporary measure (I hate doing this) I went into the ion_auth_model and changed all the 1's and 0's for the active field to 'yes','no' and changed the 'users' table to be an 'enum' table with those values.
ISSUE 2(re: issue 1): Now, when I run find_one_by_id($user_id) it returns an empty array. I used a debug_query and copied and the resulting query and ran it directly against the database and it returns a record.
QUESTION: When this runs in fuel, do you think it's looking in the fuel_users table? Why would it return an empty recordset even though the query works when run directly?
Comments
UPDATE:
For anyone else who wonders about this, I added this to the model and it fixed the issue of the 'active' field defaulting to 'yes','no'...
public $boolean_fields = array('active');
Now the query looks like this...
SELECT `users`.* FROM `users` WHERE `id` = '2' AND `users`.`active` = 1 LIMIT 1
But issue 2 remains. I can run the above query directly and it returns a record but when being processed in the app it returns an empty array.
I created a controller instead of doing the opt-in controller thing and put this in the index function:
When I echo json_encode($user) in the view I still get an empty object (
{}
) but when I echo $first_name I actually get the first_name value. How do I pass the entire $user array to the view? Do I have to pass each individual variable from the controller?I must be doing something wrong. Any help clarifying would be greatly appreciated.
Is $user returning an array or an object? If an object, I'd suggest converting it to an array so that json_encode knows how to deal with it.
@swampthang are you able to share your complete solution with ion_auth? I'm in the same situation. That would be great!