Solved

How can I fix Fatal error: Call to a member function convertGuestToMember() on a non-object

Posted on 2013-05-29
2
484 Views
Last Modified: 2013-06-24
I am trying to build a Single Sign On and getting an error. Very basic PHP knowledge. This is the error I am getting:

Fatal error: Call to a member function convertGuestToMember() on a non-object in E:\inetpub\wwwroot\forum\admin\sources\classes\session\sso.php on line 81

Here is my full code for this page:

<?php

    if ( ! defined( 'IN_IPB' ) )
{
    print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
    exit();
}

class ssoSessionExtension{

    public function __construct(ipsRegistry $registry)
    {   
        session_start();  
        return;     
    }

    public function checkSSOForGuest( $type='create' )
    {
        if(isset($_SESSION['member_data']))
        {
            $member_data    =   $_SESSION['member_data'];           
            $email          =   $member_data['email'];
            $member_exists  =   IPSMember::checkByEmail($email);

            if($member_exists)
            {
                $member         = IPSMember::load($email,'all','email');
                $member_logged  = ips_MemberRegistry::setMember(intval($member['member_id']));
            }   
            else
            {
                $member    =    IPSMember::create(
                                    array(
                                        'members' => array(
                                                            'name'                    =>    $member_data['username'],
                                                            'members_display_name'    =>    $member_data['members_display_name'],
                                                            'md5_hash_password'       =>    $member_data['password'],
                                                            'email'                   =>    $member_data['email'],
                                                    )
                                    ), false, true, false   
                              );    

                $member_logged = ips_MemberRegistry::setMember($member['member_id']);

                /* Set session up */
                if($member['member_id'])
                {
                    $privacy = IPSMember::isLoggedInAnon( $member );
                    ips_MemberRegistry::sessionClass()->convertGuestToMember( array( 'member_name'  => $member['members_display_name'],
                                                                                     'member_id'    => $member['member_id'],
                                                                                     'member_group' => $member['member_group_id'],
                                                                                     'login_type'   => $privacy ) );
                }
            }   
            return;
        }
        else
        {
        //  $member_logged = ips_MemberRegistry::setMember(0);
            return;
        }
    }

    public function checkSSOForMember( $type='create' )
    {
        if(isset($_SESSION['member_data']))
        {
            $member_data    =   $_SESSION['member_data'];
            $email          =   $member_data['email'];
            $member_exists  =   IPSMember::checkByEmail($email);

            if($member_exists)
            {
                $member         = IPSMember::load($email,'all','email');
                $member_logged  = ips_MemberRegistry::setMember($member['member_id']);

                /* Set session up */
                if($member['member_id'])
                {
                    $privacy = IPSMember::isLoggedInAnon( $member );
                    ips_MemberRegistry::sessionClass()->convertGuestToMember( array( 'member_name'  => $member['members_display_name'],
                                                                                     'member_id'    => $member['member_id'],
                                                                                     'member_group' => $member['member_group_id'],
                                                                                     'login_type'   => $privacy ) );
                }
            }
        }
    }
}

Open in new window

0
Comment
Question by:theideabulb
2 Comments
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39206548
The message is fairly self-explanatory.  Instantiation of the object did not occur.

ips_MemberRegistry::sessionClass() is not an object. You can use var_dump() to explore the characteristics of these data elements.
0
 
LVL 33

Expert Comment

by:Slick812
ID: 39206709
greetings theideabulb, although your fatal errors tells you it is line 81, in this code that you show, the actual problem is in your use of CLASS ips_MemberRegistry and it's static function sessionClass(), ,although you have code that has this function sessionClass() returning an OBJECT, it does Not return an object, so your code Fatals. You need to use more correct code for the  CLASS ips_MemberRegistry and it's static function sessionClass()   , but I know nothing about the CLASS ips_MemberRegistry , so I can not help you without more info for that.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now