PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, May 15, 2022

[FIXED] How to Auto Login After Registration in WordPress with core php

 May 15, 2022     authentication, user-registration, wordpress, wordpress-hook, wordpress-theming     No comments   

Issue

I've been trying for days now to take users who have just registered to my WordPress site and automatically log them in and then redirect them to a URL of my choice.

By default, WordPress sends you a username and a password, then you must log in manually. This is a total pain. How can i overcome this.

I have my own registration page(core php page) which successfully adds users into DB. But the point is, i should avoid users to login again.

Once registration is done, it should automatically redirects to home page or profile page.

I am a newbie to wordpress functionalities. It would be grateful if someone(who have knowledge on core functionality of wordpress) at least suggests a way/solution.

Looking forward.
Thanks


Solution

Thanks for your support guys..i did on my own with the following code..thanks for your time and support :)

<i>$getdetails= mysql_fetch_array(mysql_query("SELECT * FROM `wp_users` WHERE `ID`='$user_id'"));
$username=$getdetails['user_login'];


$creds = array();
$creds['user_login'] = $username;
$creds['user_password'] = $password;
$creds['remember'] = true;

    $user = wp_signon( $creds, false );
    if ( is_wp_error($user) ){
        echo $user->get_error_message();
    }else{
        wp_redirect( home_url() );
    }


Answered By - smallerik
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing