Solved

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

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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 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 …

830 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