Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect to display status as active when user_joined is 0. "pending activation" locale is needed. #2380

Open
FrederickChan opened this issue Feb 15, 2022 · 2 comments

Comments

@FrederickChan
Copy link
Member

Describe the bug
Add new user into database with email verification on. (Where user need to click on activation link)

$data = fusion_get_user(2);
echo getuserstatus($data['user_status']); // will generate return as 'active'

Version

All

Expected behavior

$data = fusion_get_user(2);
echo ($data['user_joined'] ? getuserstatus($data['user_status']); : 'Pending Activation')

** Improvisation to getuserstatus **

function getuserstatus($status, $user_joined)

@FrederickChan
Copy link
Member Author

FrederickChan commented Feb 15, 2022

English/global.php

$locale['status_pending'] = "Pending Activation";

core_functions_include.php

/**
 * Get a user status by the numeric code of status.
 *
 * @param int $userstatus Status code 0 - 8.
 * @param int $join_timestamp
 *
 * @return string|null The name of the given user status, null if it does not exist.
 */
function getuserstatus(int $userstatus, int $join_timestamp = 0)
: ?string {

    $locale = fusion_get_locale();

    if ( $join_timestamp ) {
        return ( $userstatus >= 0 and $userstatus <= 8 ) ? $locale[ 'status' . $userstatus ] : NULL;
    }

    return $locale['status_pending'];
}

@karrak1
Copy link
Contributor

karrak1 commented Jul 1, 2023

English/global.php

$locale['status_pending'] = "Pending Activation";

core_functions_include.php

 * Get a user status by the numeric code of status.
 *
 * @param int $userstatus Status code 0 - 8.
 * @param int $join_lastvisit 
 *
 * @return string|null The name of the given user status, null if it does not exist.
 */
function getuserstatus(int $userstatus, int $join_lastvisit = 0)
: ?string {

    $locale = fusion_get_locale();

    if ( $join_lastvisit ) {
        return ( $userstatus >= 0 and $userstatus <= 8 ) ? $locale[ 'status' . $userstatus ] : NULL;
    }

    return $locale['status_pending'];
}

user_joined always has a value, I would use user_lastvisit instead, it has no value until the user has logged in

karrak1 added a commit that referenced this issue Jul 1, 2023
test please
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants