diff --git a/membersince/membersince.php b/membersince/membersince.php index 20e41ac9..448b8cf2 100644 --- a/membersince/membersince.php +++ b/membersince/membersince.php @@ -9,6 +9,7 @@ use Friendica\Core\Hook; use Friendica\DI; +use Friendica\Model\User; use Friendica\Util\DateTimeFormat; function membersince_install() @@ -18,6 +19,18 @@ function membersince_install() function membersince_display(array &$b) { + $uid = DI::userSession()->getLocalUserId(); + + if ($uid === false) { + return; + } + + $user = User::getById($uid, ['register_date']); + + if ($user === false || !array_key_exists('register_date', $user)) { + return; + } + if (DI::appHelper()->getCurrentTheme() == 'frio') { // Works in Frio. $doc = new DOMDocument(); @@ -38,7 +51,7 @@ function membersince_display(array &$b) $label->setAttribute('class', 'col-lg-4 col-md-4 col-sm-4 col-xs-12 profile-label-name text-muted'); // The div for the register date of the profile owner. - $entry = $doc->createElement('div', DateTimeFormat::local(DI::appHelper()->profile['register_date'])); + $entry = $doc->createElement('div', DateTimeFormat::local($user['register_date'])); $entry->setAttribute('class', 'col-lg-8 col-md-8 col-sm-8 col-xs-12 profile-entry'); $div->appendChild($hr); @@ -49,6 +62,6 @@ function membersince_display(array &$b) $b = $doc->saveHTML(); } else { // Works in Vier. - $b = preg_replace('/<\/dl>/', "\n\n\n
\n
" . DI::l10n()->t('Member since:') . "
\n
" . DateTimeFormat::local(DI::appHelper()->profile['register_date']) . "
\n
", $b, 1); + $b = preg_replace('/<\/dl>/', "\n\n\n
\n
" . DI::l10n()->t('Member since:') . "
\n
" . DateTimeFormat::local($user['register_date']) . "
\n
", $b, 1); } }