?
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
?
491 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…
Suggested Courses

771 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