init_variables();
}
/**
* Translated defaults (WordPress 6.7+: run at init after textdomain load).
*
* @since 1.2.9
*/
function init_translated_config() {
if ( ! empty( $this->email_notifications ) ) {
return;
}
$this->email_notifications = apply_filters( 'amem/email/notifications', array(
'welcome_email' => array(
'key' => 'welcome_email',
'title' => __( 'Account Welcome Email', 'advanced-members' ),
'subject' => 'Welcome to {site_name}!',
'body' => 'Hi {display_name},
' .
'Thank you for signing up with {site_name}! Your account is now active.
' .
'To login please visit the following url:
' .
'{login_url}
' .
'Your account e-mail: {email}
' .
'Your account username: {username}
' .
'If you have any problems, please contact us at {admin_email}
' .
'Thanks,
' .
'{site_name}',
'description' => __('Whether to send the user an email when their account is automatically approved', 'advanced-members'),
'recipient' => 'user',
'default_active' => true
),
'checkmail_email' => array(
'key' => 'checkmail_email',
'title' => __( 'Account Activation Email', 'advanced-members' ),
'subject' => 'Please activate your account',
'body' => 'Hi {display_name},
' .
'Thank you for signing up with {site_name}! To activate your account, please click the link below to confirm your email address:
' .
'{user_activation_link}
' .
'If you have any problems, please contact us at {admin_email}
' .
'Thanks,
' .
'{site_name}',
'description' => __('Send the user an email when their account needs e-mail activation. (This option is always on)', 'advanced-members'),
'recipient' => 'user',
'default_active' => true,
'force_active' => true,
),
'deletion_email' => array(
'key' => 'deletion_email',
'title' => __( 'Delete Account Email', 'advanced-members' ),
'subject' => 'Your account has been deleted',
'body' => 'Hi {display_name},
' .
'This is an automated email to let you know your {site_name} account has been deleted. All of your personal information has been permanently deleted and you will no longer be able to login to {site_name}.
' .
'If your account has been deleted by accident please contact us at {admin_email}
' .
'Thanks,
' .
'{site_name}',
'description' => __('Whether to send the user an email when their account is deleted', 'advanced-members'),
'recipient' => 'user',
'default_active' => true
),
'resetpw_email' => array(
'key' => 'resetpw_email',
'title' => __( 'Password Reset Email', 'advanced-members' ),
'subject' => 'Reset your password',
'body' => 'Hi {display_name},
' .
'We received a request to reset the password for your account. If you made this request, click the link below to change your password:
' .
'{password_reset_link}
' .
'If you didn\'t make this request, you can ignore this email
' .
'Thanks,
' .
'{site_name}',
'description' => __('Send an email when users changed their password (This option is always on)', 'advanced-members'),
'recipient' => 'user',
'default_active' => true,
'force_active' => true,
),
'changedpw_email' => array(
'key' => 'changedpw_email',
'title' => __( 'Password Changed Email', 'advanced-members' ),
'subject' => 'Your {site_name} password has been changed',
'body' => 'Hi {display_name},
' .
'You recently changed the password associated with your {site_name} account.
' .
'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}
' .
'Thanks,
' .
'{site_name}',
'description' => __('Whether to send the user an email when they requests to reset password (Recommended, please keep on)', 'advanced-members'),
'recipient' => 'user',
'default_active' => true,
),
// Disabled
// 'changedaccount_email' => array(
// 'key' => 'changedaccount_email',
// 'title' => __( 'Account Updated Email', 'advanced-members' ),
// 'subject' => 'Your account at {site_name} was updated',
// 'body' => 'Hi {display_name},
' .
// 'You recently updated your {site_name} account.
' .
// 'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}
' .
// 'Thanks,
' .
// '{site_name}',
// 'description' => __('Whether to send the user an email when they updated their account', 'advanced-members'),
// 'recipient' => 'user',
// 'default_active'=> true
// ),
'notification_new_user' => array(
'key' => 'notification_new_user',
'title' => __( 'New User Notification', 'advanced-members' ),
'subject' => '[{site_name}] New user account',
'body' => '{display_name} has just created an account on {site_name}. To view their profile click here:
' .
'{user_profile_link}
' .
'Registered e-mail: {email}
' .
'Registered username: {username}',
'description' => __('Whether to receive notification when a new user account is created', 'advanced-members'),
'recipient' => 'admin',
'default_active' => true,
),
'notification_review_user' => array(
'key' => 'notification_review_user',
'title' => __( 'User Awaiting Review Notification', 'advanced-members' ),
'subject' => '[{site_name}] New user awaiting review',
'body' => '{display_name} has just created an account on {site_name} and is awaiting administrative review. To view their profile and approve them, click here:
' .
'{user_profile_link}
' .
'Registered e-mail: {email}
' .
'Registered username: {username}',
'description' => __('Whether to receive notification when a new user account requires admin approval', 'advanced-members'),
'recipient' => 'admin',
'default_active' => true,
),
'notification_deletion' => array(
'key' => 'notification_deletion',
'title' => __( 'Account Deletion Notification', 'advanced-members' ),
'subject' => '[{site_name}] Account deleted',
'body' => '{display_name} has just deleted their {site_name} account.',
'description' => __('Whether to receive notification when an account is deleted', 'advanced-members'),
'recipient' => 'admin'
),
));
$this->core_forms = array(
'register',
'login',
'account',
);
$this->amem_default_form_meta = array(
'register' => array(
'form_key' => 'form_' . uniqid(),
'select_type' => 'registration',
'regist_role' => 'subscriber',
'regist_status' => 'approve',
'after_registration' => 'redirect_home',
'description' => '',
'amem_core_form' => 'register',
'num_of_submissions' => 0,
'form_num_of_views' => 0
),
'login' => array(
'form_key' => 'form_' . uniqid(),
'select_type' => 'login',
'after_login' => 'redirect_home',
'description' => '',
'amem_core_form' => 'login',
'num_of_submissions' => 0,
'form_num_of_views' => 0
),
'account' => array(
'form_key' => 'form_' . uniqid(),
'select_type' => 'account',
'description' => '',
'amem_core_form' => 'account',
'num_of_submissions' => 0,
'form_num_of_views' => 0
),
);
$this->amem_default_field_group = array(
'location' => array(array(array(
'param' => 'amem_form',
'operator' => '==',
'value' => '',
))),
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'description' => '',
'show_in_rest' => 0
);
$this->amem_default_fields = $this->build_default_fields();
$this->core_pages = array(
'register' => array( 'label' => __( 'Registration', 'advanced-members' )),
'login' => array( 'label' => __( 'Login', 'advanced-members' )),
'password-reset' => array('label' => __( 'Password Reset', 'advanced-members' )),
'logout' => array('label' => __( 'Logout', 'advanced-members' )),
'account' => array('label' => __( 'Account', 'advanced-members' )),
'account-password' => array('label' => __( 'Change Password', 'advanced-members' )),
'account-delete' => array('label' => __( 'Delete Account', 'advanced-members' )),
);
//default settings
$this->default_settings = array(
);
}
/**
* Default ACF fields for core forms.
* User-facing strings use __() so install stores the current site locale.
*
* @return array
*/
function build_default_fields() {
$wrapper = array(
'width' => '',
'class' => '',
'id' => '',
);
$username_settings = array(
'aria-label' => '',
'type' => 'username',
'instructions' => '',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => $wrapper,
'default_value' => '',
'allow_edit' => 0,
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
);
$login_username_settings = $username_settings;
$password_settings = array(
'aria-label' => '',
'type' => 'user_password',
'instructions' => '',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => $wrapper,
'password_strength' => 3,
'force_edit' => 0,
'edit_password' => __( 'Edit Password Button', 'advanced-members' ),
'cancel_edit_password' => __( 'Cancel', 'advanced-members' ),
'placeholder' => '',
'prepend' => '',
'append' => '',
'show_pass_confirm' => 0,
);
// Registration includes password confirmation by default.
$register_password_settings = $password_settings;
$register_password_settings['show_pass_confirm'] = 1;
$register_password_settings['confirm_label'] = __( 'Password Confirm', 'advanced-members' );
$register_password_settings['confirm_placeholder'] = '';
$email_settings = array(
'aria-label' => '',
'type' => 'user_email',
'instructions' => '',
'required' => 1,
'conditional_logic' => 0,
'wrapper' => $wrapper,
'default_value' => '',
'set_as_username' => 0,
'placeholder' => '',
'prepend' => '',
'append' => '',
);
return array(
'register' => array(
array(
'title' => __( 'Username', 'advanced-members' ),
'type' => 'username',
'settings' => $username_settings,
),
array(
'title' => __( 'Email', 'advanced-members' ),
'type' => 'user_email',
'settings' => $email_settings,
),
array(
'title' => __( 'Password', 'advanced-members' ),
'type' => 'user_password',
'settings' => $register_password_settings,
),
),
'login' => array(
array(
'title' => __( 'Username or Email', 'advanced-members' ),
'type' => 'username',
'settings' => $login_username_settings,
),
array(
'title' => __( 'Password', 'advanced-members' ),
'type' => 'user_password',
'settings' => $password_settings,
),
),
'account' => array(
array(
'title' => __( 'Username', 'advanced-members' ),
'type' => 'username',
'settings' => $username_settings,
),
array(
'title' => __( 'Email', 'advanced-members' ),
'type' => 'user_email',
'settings' => $email_settings,
),
),
);
}
function get_core_pages($force=false) {
if ( $force || !did_action( 'amem/core/pages' ) )// prevent duplicates
$this->core_pages = apply_filters( 'amem/core/pages', $this->core_pages );
return $this->core_pages;
}
/**
* Set variables
*/
function init_variables() {
$this->options = get_option( 'amem_options', array() );
}
function get_after_url( $data ) {
switch ($data) {
case 'after_logout':
$value = '';
if( 'redirect_home' == $this->options['logout']['_after_logout'] ){
$value = home_url();
}elseif ( isset($this->options['logout']['_logout_redirect_url']) && !empty($this->options['logout']['_logout_redirect_url']) ) {
$value = $this->options['logout']['_logout_redirect_url'];
}
return $value;
break;
}
}
}
amem()->register_module('config', Config::getInstance());