Solved

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

Posted on 2013-05-29
2
481 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 108

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

708 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