Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2013-05-29
2
Medium Priority
?
501 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 111

Accepted Solution

by:
Ray Paseur earned 2000 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 34

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month21 days, 3 hours left to enroll

810 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