Login to WP from PHP
-
I’m working with custom pages in WP and I have beeb making a few pages.
In the database I have created a new table for profiles.I have made a custom PHP page where you can create a new profile. At the same time it creates a new WP user.
I have also made a custom PHP page where you can login to the system (new table).
Here in this file I want to also let the user login to WP, but here I have failed so far.
Heres the code I have tried:
$creds = array( 'user_login' => 'username', 'user_password' => 'password', 'rememember' => true ); $user = wp_signon( $creds, true )
When I then go to /wp-admin page is okay, but I have an forum page that only WP users can se and this page I’m not allowed to visit.
If I login to WP with the same credential the normal way (wp-login) I can see the forum fine.
So my question is simply:
How do I login to a WP site in PHP code?
After login I want to go the the main page of the site.
- The topic ‘Login to WP from PHP’ is closed to new replies.