Jump to content

Get user information ?


Alex914

Recommended Posts

Posted

Hello,

How get the user information (username, group...) on an external site?

Like IPS3

require_once( './initdata.php' );

require_once( IPS_ROOT_PATH . 'sources/base/ipsRegistry.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' );/*noLibHook*/
$registry = ipsRegistry::instance();
$registry->init();

// Fetch details
$member = $registry->member()->fetchMemberData();

// Print the display

//print_r($registry->member()->fetchMemberData());
print $member['members_display_name'];
//print $member['member_id'];

Thanks

Posted
<?php
// Initialize IPS4 Framework
require_once( './init.php' );

// Indicate that we should consider this a front-end session so we can obtain the currently logged in users information.
\IPS\Session\Front::i();

// Grab the currently Logged In user.
$member = \IPS\Member::loggedIn();

// Output their username
print $member->name;

 

  • 2 months later...
Posted

Hello,

The API does not work (4.0.0 Beta 7a)

1) I create demo file (demo.php) in my server and load IPS.

<?php
// Initialize IPS4 Framework
require_once( 'forums/init.php' );

// Indicate that we should consider this a front-end session so we can obtain the currently logged in users information.
\IPS\Session\Front::i();

// Grab the currently Logged In user.
$member = \IPS\Member::loggedIn();

print_r($member);

// Group 2 = Guests
if ($member->member_group_id == 2) {
	
	echo 'Guests';
	
} else {
	
	echo '<br><br>';
	echo 'Hello ';
	echo $member->name;
	
}

2) I'am logged on my board

Capture_d’écran_2015-02-07_à_03.32

3) On my demo.php page, no logged :(

IPS\Member Object
(
    [_followData] => 
    [_group] => 
    [restrictions:protected] => 
    [modPermissions:protected] => 
    [calculatedLanguageId:protected] => 
    [markers] => Array
        (
        )

    [markersResetTimes:protected] => Array
        (
        )

    [previousName:protected] => 
    [sessionData:protected] => 
    [_lang:protected] => 
    [_url:protected] => 
    [profileFields] => 
    [_reputationData:protected] => 
    [_following:protected] => Array
        (
        )

    [reportCount:protected] => 
    [ignorePreferences:protected] => 
    [_data:protected] => Array
        (
            [member_group_id] => 2
            [mgroup_others] => 
            [joined] => 1423276886
            [ip_address] => 85.XX
            [timezone] => UTC
            [allow_admin_mails] => 1
            [pp_photo_type] => 
            [member_posts] => 0
            [pp_main_photo] => 
            [pp_thumb_photo] => 
            [failed_logins] => 
            [pp_reputation_points] => 0
            [signature] => 
        )

    [_new:protected] => 1
    [changed] => Array
        (
            [member_group_id] => 2
            [mgroup_others] => 
            [joined] => 1423276886
            [ip_address] => 85.XX
            [timezone] => UTC
            [allow_admin_mails] => 1
            [pp_photo_type] => 
            [member_posts] => 0
        )

    [skipCloneDuplication] => 
)

 

Posted

It work only if my demo.php file is in board directory, why ?

demo.php in / = no work, no logged

require( 'forums/init.php' );

demo.php in /forums = ok

require( 'init.php' );

 

  • 9 months later...
  • 6 months later...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...