• http://
  • .yourcommunify.com
  • Go!

Single sign on

Single Sign On (S2O)

Use this code. Metas have to been rendered at tag.

    $accountId = '[ACCOUNT ID]';
    $data = array(
        'email'             => '[USER EMAIL]',
        'name'              => '[USER NAME]',
        'surname'           => '[USER SURNAME]',
        'file_url'          => '[USER PROFILE IMAGE URL]',
        'background_url'    => '[USER BACKGROUND IMAGE URL]',
        'language_id'       => '[LANG ID]'
    );
    echo \Communify\S2O\S2OClient::factory()->login($accountId, $data)->metas();

Single Sign On (S2O) and Wordpress

    function getAvatarUrl($id)
    {
        $avatar = get_avatar($id);
        preg_match("/src=\"(.*?)\"/i", $avatar, $matches);
        $url = $matches[1];
        $urlArray = parse_url($url);
        return 'http://'.$urlArray['host'].$urlArray['path'];
    }

    $currentUser = wp_get_current_user();
    $accountId = '[ACCOUNT ID]';
    if($currentUser->ID != 0)
    {
        $data = array(
            'email'             => $currentUser->user_email,
            'name'              => $currentUser->user_firstname,
            'surname'           => $currentUser->user_lastname,
            'file_url'          => getAvatarUrl($currentUser->ID)
        );
        echo \Communify\S2O\S2OClient::factory()->login($accountId, $data)->metas();
    }