• Okay basically, I have a music project I picked up from a friend that ive been working on for the the past couple of weeks. Its divided into three parts, A main website (powered by wordpress) – a custom user panel (powered by codeigniter) – and a radio/music player (Powered by codeigniter).

    Oddly enough, all three parts have their own login system. So users need to register on each separate area which is horrible. I am not worried about the custom user panel because that is being removed and we will just be themeing the original wordpress dashboard to our liking.

    Basically I want to combine the radio/music player with the wordpress login/register system so the usernames and passwords are the same throughout the main wordpress site and the musicplayer.

    The radio uses a basic login/register system and here’s the corresponding functions:

    public function uregister() {
        $this->load->helper( array('form') );
        if( $_POST['submit'] ) {
            $data = array("ra_fullname"=>$_POST['fname'],
                          "ra_email"=>$_POST['uemail'],
                          "ra_password"=>$_POST['upassword']);
            $this->db->insert('ws_radio_user', $data);
            redirect( site_url() );
        }
    
        $data = array();
        $this->load->view('user_register', $data );
    } 
    
    public function ulogin() {
        $this->load->helper( array('form') );
        if( isset( $_POST['submit']) ) {
            $data = $this->db->query("select * from ws_radio_user where ra_email = '".$_REQUEST['lemail']."' and ra_password = '".$_REQUEST['lupassword']."'")->row();
            if( $data ) {
                $sess_array = array(
                                'id' => $data->uid,
                                'username' => $data->ra_email
                              );
                $this->session->set_userdata('logged_in', $sess_array);
                redirect('https://radio.#.com');
            } else {
               $data = array();
               $data['error'] = "username password does not match";
               redirect('https://radio.#.com');
            }
        }
    
        $data = array();
        $this->load->view('login_view', $data );
    }
    public function logout() {
        $this->load->helper( array('form') );
        $this->session->unset_userdata('logged_in');
        $this->session->sess_destroy();
        redirect('https://radio.#.com', 'refresh');
    }

    I am nowhere near a professional when it comes to php, so any insight would be extremely helpful, in replacing this login (which obviously only reads and writes plaintext) with the wordpress login system.

    Also both the wordpress tables and the radio tables are in the same database ^.^

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I would suggest using WP as the main user management engine. Every function related to this in WP should have a filter or action you could hook into to do related functions on the other platforms.

    For example, when a new user registers in WP, wp_insert_user() is called to make the needed entries to the DB. This function has a ‘user_register’ action that you can hook into. Your hook function will be passed the new user ID, with this, you can get any pertinent information that needs to be added to the other platform’s tables to register a user there dynamically via code.

    A similar process is followed for every user management function such as updating data, logging in, logging out, etc. Determine which functions are used in each case and check the source code to determine which hook would work for your needs.

    If the tables are all in the same DB, you can use $wpdb methods to access the tables of other platforms, which is a little easier than straight PHP mysql functions.

Viewing 1 replies (of 1 total)
  • The topic ‘Use wordpress's login for outside standalone application?’ is closed to new replies.