';
return $return;
}
/**
* registrationForm method will generate html for sign up form
* @param $attributes
* @return string
*/
public function registrationForm($attributes)
{
if (get_current_user_id()) {
return '
' . __('You are already logged in.', 'fluent-support') . '
';
}
$attributes = $this->getShortcodes($attributes);
$this->handleAlreadyLoggedIn($attributes);
if ($this->authProvider() == 'fluent_auth') {
return (new \FluentAuth\App\Hooks\Handlers\CustomAuthHandler())->registrationForm($attributes);
}
$customFieldsKey = apply_filters('fluent_support/custom_registration_form_fields_key', Helper::getBusinessSettings('custom_registration_form_field'));
if (!empty($customFieldsKey)) {
add_filter('fluent_support/registration_form_fields', function($fields) use ($customFieldsKey) {
return $this->addCustomFieldsToRegistrationForm($fields,$customFieldsKey);
});
}
$registrationFields = static::getSignupFields();
$hide = $attributes['hide'] == 'true' ? 'hide' : '';
$this->loadAssets($hide);
return $this->buildRegistrationForm($registrationFields, $hide, $attributes);
}
// This method `buildRegistrationForm` will generate html for sign up form
private function buildRegistrationForm($registrationFields, $hide, $attributes)
{
$registrationForm = '
';
return $registrationForm;
}
public function restPasswordForm($attributes)
{
if (get_current_user_id()) {
return '
' . __('You are already logged in.', 'fluent-support') . '
';
}
$attributes = $this->getShortcodes($attributes);
if ($this->authProvider() == 'fluent_auth') {
return (new \FluentAuth\App\Hooks\Handlers\CustomAuthHandler())->restPasswordForm($attributes);
}
$this->handleAlreadyLoggedIn($attributes);
$resetPasswordFields = static::resetPasswordFields();
$hide = $attributes['hide'] == 'true' ? 'hide' : '';
$this->loadAssets($hide);
return $this->buildResetPassForm($resetPasswordFields, $hide, $attributes);
}
// This method `buildResetPassForm` will generate html for password reset form
private function buildResetPassForm($resetPasswordFields, $hide, $attributes)
{
$restePasswordForm = '
';
$restePasswordForm .= '
';
return $restePasswordForm;
}
/**
* authForm will render the login form html
* @param $attributes
* @return string
*/
public function authForm($attributes)
{
if (get_current_user_id()) {
// translators: %s is the URL to the support portal
return '
' . sprintf(__('You are already logged in. Go to support portal', 'fluent-support'), Helper::getPortalBaseUrl()) . '
';
}
$attributes = $this->getShortcodes($attributes);
if ($this->authProvider() == 'fluent_auth') {
return (new \FluentAuth\App\Hooks\Handlers\CustomAuthHandler())->authForm($attributes);
}
$authForm = do_shortcode('[fluent_support_login show-signup=true show-reset-password=true]');
return $authForm;
}
/**
* renderField method will generate html for a field
* @param $fieldName
* @param $field
* @return string
*/
private function renderField($fieldName, $field)
{
$fieldType = Arr::get($field, 'type');
$isRequired = Arr::get($field, 'required');
$isRequired = $isRequired ? 'is-required' : '';
$html = '