How to use Wordpress function with new database - database

I am working on WordPress registration and login functionality. Actually I have 10 sites and I am making a single database table where these 10 sites can easily login and registered with same email and password. I mean same email and password can apply on these 10 sites login form through this single database table.
In my 10 sites there is one WordPress site. So I want the customize the registration and login functionality of this.
For my WordPress site I have make connect it with new database like:
$mydb = new wpdb('user','password','database','hostname');
after that I have check the database connection. it is working properly
Now I am getting a problem. I want to create a new user through this function
wp_create_user( $sanitized_user_login, $_POST['password'], $user_email );
when i am calling it through my new database connection like:
$mydb->wp_create_user( $sanitized_user_login, $_POST['password'], $user_email );
it is giving me blank result. So please tell me how can i get the all function of WordPress and use it for new database connection and create a new user in new database
Thanks

wp_create_user is a wordpress function
wdpb is used to work with db tables, there is no function wp_crete_user in wpdb. So you need to read the doc to know how to add a user in users table wpdb

Related

How to skip login in cakephp 2.6.7?

I have an old cakephp application which requires login. I was working with the tables in phpmyadmin and I accidentally deleted the user login/password entry from the table. Now I am not able to login in the cakephp application. I tried to create a login entry in the table but I am not sure how to insert a password in it. it is not working with plain text password. I guess, app is looking for encrypted password which I don't know how to add to the table.
Either I need to disable the login from the cakephp application code and direct the user straight to the main page of the app
Or I need to encrypt the password correctly and insert it in the table.
Please help! I am not sure how to achieve either of these solutions.
Go to your Users Controller and add the actions you need to create and save a new user:
$this->Auth->allow('display','save');
so, you'll be able to anter to that controller actions without any login.

backand : issues with user creation, deletion, update

I'm creating an app using ionic/angularjs using Backand as the backend service. I have it setup to use a MySQL database.
1) When I create a user through the SDK (version 1.8.2 from the CDN), the user shows up in Registered Users area but does not get a row in the 'users' table. Someone mentioned that I should have Anonymous Access set to User as they said this is a permissions issue but that did not solve the issue for me.
2) I can manually add a user through the Backand GUI and the user gets a row in the 'users' table as I would expect.
3) I can not manually delete users or rows in the 'users' table through the Backand GUI. I get an error stating that the "Delete My App User" failed to perform. You can't specify target table 'users' for update in FROM clause. I haven't modified the Security Actions at all. They're all default. Updating a user receives a similar error.
4) I created a blank app in Backand and updated my app with the new tokens and app name. I was able to login to that app using login credentials that were created on the original app but were not a part of this app. Does this mean users can access any Backand once registered with one app on the system?
Am I just really missing how 'users' registration and logins are suppose to work in Backand?
Any guidance would be appreciated. Thank you in advance.
You can read more on the Back& security concept here.
User can only access to the app he was registred into. In your case I believe the second app has anonymus access, so you have signed in to the first app and got access token, and using the anonymus header you accessed the second app.
Please use incognito window mode for the second app and then you could debug two apps.
You can also review Back& User example to play around with the security.

cakephp 3 application transfer to webhoster

I'm trying to transfer a cakephp3 application from my local linux server to a online webhoster.
I managed to migrate the database and put it online. The only way to connect to the internet for me is through a proxy right now. However this proxy blocks the website, so I'm using a webproxy (proxfree.net and hide.me) to access the website.
Whenever I try to login I get a 'invalid username or password'.
When I try to create a new user, it saves a record, but with an empty field for the pseudonym (username).
I wrote a test for the database connection
$db = ConnectionManager::get('default');
echo "To database ".($db->isConnected()?"connected":"disconnected")."\n";
It says it's connected to the database. I'm also able to print the usernames on the login-site, so the database-connection works definitely.
Login: marcusmoenius.bplaced.net/app/users/login
Add user: marcusmoenius.bplaced.net/app/users/add
Does anyone know, why I can't login? Is anyone else able to login? It worked on my local machine
example username and password:
username: Stella
password: Superman
OK, so it was no problem with the webspace, but with my understanding of the cakephp-functionality.
Apperantly the passwords-hashes don't match on the webhoster. So I needed to add new users with new-hashed passwords.
But the registration of new users didn't work, because I marked the pseudonym-field as not _accessible in the users-table. So when I invoked the patchEntity-method in the controller, it didn't apply the pseudonym-field and hence didn't put a valid record in the database.

Laravel database sessions

I'm building a Laravel website and I'm using the database driver to manage sessions. I created the sessions table in database and migrated with php artisan. Everything works as expected.
What I really want to do now is to check the role of the users that are online but I don't know how to get this with the fields of the sessions table in the database.
I don't really understand how the sessions table work, because I see that it registers a new row when I access to the login page, but it doesn't change when the user has logged in and when the user has logged out.
All I wanted is to check the role of the users active in the app....
Someone can help me with how to get to this?
Thank you!
I suggest you a very simple way. Just in your users table add a field called "is_online" that is 0 by default. When the user logs in , just change it to 1 and when he logs out change it back to 0. So DB::table('users')->where('is_online' , 1)->all() returns the online users.

How do I configure CodeIgniter to fetch information from a specific database?

I'm relatively new to the CodeIgniter framework (I'm using v2).
I'll need to write an application, in such a way that users do their login to a central DB. After successfully logging in, the user is then redirected to their back-end, which should connect to their specific database, which is stored in the login table for each user.
How can I set the configs for CodeIgniter to be able to fetch information from the correct DB?
I want to achieve something like this:
$config['default']['database'] = "Logins"
$config['specific']['database'] = get_user_database();
Is this possible in CodeIgniter?
At first impression, you have two options:
Set the config value as
$this->config->set_item('specific', array('database' => get_user_database()));
Use Hooks, could be at pre_controller hook point

Resources