/**
  * Validate the password field.
  *
  * @access public
  * @since 1.0.0
  * @return void
  */
 public static function validate_password_field($passed, $fields, $values)
 {
     $pwd = $values['password_update']['password'];
     $pwd_strenght = wpum_get_option('password_strength');
     if (empty($pwd)) {
         return new WP_Error('password-validation-error', __('Enter a password.', 'wpum'));
     }
     // Check strenght
     $containsLetter = preg_match('/[A-Z]/', $pwd);
     $containsDigit = preg_match('/\\d/', $pwd);
     $containsSpecial = preg_match('/[^a-zA-Z\\d]/', $pwd);
     if ($pwd_strenght == 'weak') {
         if (strlen($pwd) < 8) {
             return new WP_Error('password-validation-error', __('Password must be at least 8 characters long.', 'wpum'));
         }
     }
     if ($pwd_strenght == 'medium') {
         if (!$containsLetter || !$containsDigit || strlen($pwd) < 8) {
             return new WP_Error('password-validation-error', __('Password must be at least 8 characters long and contain at least 1 number and 1 uppercase letter.', 'wpum'));
         }
     }
     if ($pwd_strenght == 'strong') {
         if (!$containsLetter || !$containsDigit || !$containsSpecial || strlen($pwd) < 8) {
             return new WP_Error('password-validation-error', __('Password must be at least 8 characters long and contain at least 1 number and 1 uppercase letter and 1 special character.', 'wpum'));
         }
     }
     // Check if matches repeated password
     if ($pwd !== $values['password_update']['password_repeat']) {
         return new WP_Error('password-validation-error', __('Passwords do not match.', 'wpum'));
     }
     return $passed;
 }
Exemplo n.º 2
0
 /**
  * Replaces the default wp_new_user_notification function of the core.
  *
  * Email login credentials to a newly-registered user.
  * A new user registration notification is also sent to admin email.
  *
  * @since 1.0.0
  * @access public
  * @return void
  */
 function wp_new_user_notification($user_id, $plaintext_pass)
 {
     $user = get_userdata($user_id);
     // The blogname option is escaped with esc_html on the way into the database in sanitize_option
     // we want to reverse this for the plain text arena of emails.
     $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
     // Send notification to admin if not disabled.
     if (!wpum_get_option('disable_admin_register_email')) {
         $message = sprintf(__('New user registration on your site %s:', 'wpum'), $blogname) . "\r\n\r\n";
         $message .= sprintf(__('Username: %s', 'wpum'), $user->user_login) . "\r\n\r\n";
         $message .= sprintf(__('E-mail: %s', 'wpum'), $user->user_email) . "\r\n";
         wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration', 'wpum'), $blogname), $message);
     }
     /* == Send notification to the user now == */
     if (empty($plaintext_pass)) {
         return;
     }
     // Check if email exists first
     if (wpum_email_exists('register')) {
         // Retrieve the email from the database
         $register_email = wpum_get_email('register');
         $message = wpautop($register_email['message']);
         $message = wpum_do_email_tags($message, $user_id, $plaintext_pass);
         WPUM()->emails->__set('heading', __('Your account', 'wpum'));
         WPUM()->emails->send($user->user_email, $register_email['subject'], $message);
     }
 }
Exemplo n.º 3
0
/**
 * Stops users from seeing the profile.php page in wp-admin.
 *
 * @since 1.0.0
 * @access public
 * @return void
 */
function wpum_remove_profile_wp_admin()
{
    if (!current_user_can('administrator') && IS_PROFILE_PAGE && wpum_get_option('backend_profile_redirect')) {
        wp_redirect(esc_url(get_permalink(wpum_get_option('backend_profile_redirect'))));
        exit;
    }
}
Exemplo n.º 4
0
/**
 * Admin Messages
 *
 * @since 1.0
 * @global $wpum_options Array of all the WPUM Options
 * @return void
 */
function wpum_admin_messages()
{
    global $wpum_options;
    $screen = get_current_screen();
    if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == true && !wpum_get_option('custom_passwords') && wpum_get_option('password_strength')) {
        add_settings_error('wpum-notices', 'custom-passwords-disabled', __('You have enabled the "Minimum Password Strength" option, the "Users custom passwords" is currently disabled and must be enabled for custom passwords to work.', 'wpum'), 'error');
    }
    if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == true && !wpum_get_option('custom_passwords') && wpum_get_option('login_after_registration')) {
        add_settings_error('wpum-notices', 'custom-passwords-disabled', __('Error: the option "Login after registration" can only work when the option "Users custom passwords" is enabled too.', 'wpum'), 'error');
    }
    if (isset($_GET['emails-updated']) && $_GET['emails-updated'] == true) {
        add_settings_error('wpum-notices', 'emails-updated', __('Email successfully updated.', 'wpum'), 'updated');
    }
    // Display Errors in plugin settings page
    if ($screen->base == 'users_page_wpum-settings') {
        // Display error if no core page is setup
        if (!wpum_get_option('login_page') || !wpum_get_option('password_recovery_page') || !wpum_get_option('registration_page') || !wpum_get_option('account_page') || !wpum_get_option('profile_page')) {
            add_settings_error('wpum-notices', 'page-missing', __('One or more WPUM pages are not configured.', 'wpum') . ' ' . sprintf(__('<a href="%s" class="button-primary">Click here to setup your pages</a>', 'wpum'), admin_url('users.php?page=wpum-settings&tab=general&wpum_action=install_pages')), 'error');
        }
        // Display error if wrong permalinks
        if (get_option('permalink_structure') == '') {
            add_settings_error('wpum-notices', 'permalink-wrong', sprintf(__('You must <a href="%s">change your permalinks</a> to anything else other than "default" for profiles to work.', 'wpum'), admin_url('options-permalink.php')), 'error');
        }
        if (isset($_GET['setup_done']) && $_GET['setup_done'] == 'true') {
            add_settings_error('wpum-notices', 'pages-updated', __('Pages setup completed.', 'wpum'), 'updated');
        }
        if (isset($_GET['message']) && $_GET['message'] == 'fields_fixed') {
            add_settings_error('wpum-notices', 'fields_fixed', __('Fields successfully fixed.', 'wpum'), 'updated');
        }
    }
    // Verify if upload folder is writable
    if (isset($_GET['wpum_action']) && $_GET['wpum_action'] == 'check_folder_permission') {
        $upload_dir = wp_upload_dir();
        if (!wp_is_writable($upload_dir['path'])) {
            add_settings_error('wpum-notices', 'permission-error', sprintf(__('Your uploads folder in "%s" is not writable. <br/>Avatar uploads will not work, please adjust folder permission.<br/><br/> <a href="%s" class="button" target="_blank">Read More</a>', 'wpum'), $upload_dir['basedir'], 'http://www.wpbeginner.com/wp-tutorials/how-to-fix-image-upload-issue-in-wordpress/'), 'error');
        } else {
            add_settings_error('wpum-notices', 'permission-success', sprintf(__('No issues detected.', 'wpum'), admin_url('users.php?page=wpum-settings&tab=profile')), 'updated notice is-dismissible');
        }
    }
    // messages for the groups and fields pages
    if ($screen->base == 'users_page_wpum-profile-fields') {
        if (isset($_GET['message']) && $_GET['message'] == 'group_success') {
            add_settings_error('wpum-notices', 'group-updated', __('Field group successfully updated.', 'wpum'), 'updated');
        }
        if (isset($_GET['message']) && $_GET['message'] == 'group_delete_success') {
            add_settings_error('wpum-notices', 'group-deleted', __('Field group successfully deleted.', 'wpum'), 'updated');
        }
        if (isset($_GET['message']) && $_GET['message'] == 'field_saved') {
            add_settings_error('wpum-notices', 'field-saved', __('Field successfully updated.', 'wpum'), 'updated');
        }
    }
    // messages for tools page
    if ($screen->base == 'users_page_wpum-tools') {
        if (isset($_GET['message']) && $_GET['message'] == 'settings_imported') {
            add_settings_error('wpum-notices', 'settings-imported', __('Settings successfully imported.', 'wpum'), 'updated');
        }
    }
    settings_errors('wpum-notices');
}
Exemplo n.º 5
0
 /**
  * Returns the correct username label on the login form
  * based on the selected login method.
  *
  * @since 1.0.0
  * @access public
  * @return string
  */
 function wpum_get_username_label()
 {
     $label = __('Username', 'wpum');
     if (wpum_get_option('login_method') == 'email') {
         $label = __('Email', 'wpum');
     } else {
         if (wpum_get_option('login_method') == 'username_email') {
             $label = __('Username or email', 'wpum');
         }
     }
     return $label;
 }
 /**
  * __construct function.
  *
  * @access public
  * @return void
  */
 public function __construct()
 {
     // retrieve login method
     $this->login_method = wpum_get_option('login_method', 'username');
     // Restore Email
     add_action('wp_ajax_wpum_restore_emails', array($this, 'restore_emails'));
     // Avatar removal method
     add_action('wp_ajax_wpum_remove_avatar', array($this, 'remove_user_avatar'));
     add_action('wp_ajax_nopriv_wpum_remove_avatar', array($this, 'remove_user_avatar'));
     // Update custom fields order
     add_action('wp_ajax_wpum_update_fields_order', array($this, 'update_fields_order'));
 }
 /**
  * Get active instance
  *
  * @access      public
  * @since       1.0.0
  * @return      object self::$instance The one true WPUM_reCAPTCHA
  */
 public static function instance()
 {
     if (!self::$instance) {
         self::$instance = new WPUM_reCAPTCHA();
         self::$instance->setup_constants();
         self::$instance->includes();
         self::$instance->load_textdomain();
         self::$where = wpum_get_option('recaptcha_location');
         self::$instance->hooks();
     }
     return self::$instance;
 }
Exemplo n.º 8
0
 /**
  * Construction function.
  *
  * @param string $file    file path.
  * @param string $item_name    item name.
  * @param string $version version of the addon.
  * @param string $author  author of the addon.
  */
 public function __construct($file, $item_name, $version, $author, $_api_url = null)
 {
     $this->file = $file;
     $this->item_name = $item_name;
     $this->version = $version;
     $this->author = $author;
     if (!empty($_api_url)) {
         $this->api_url = $_api_url;
     }
     $this->item_shortname = 'wpum_' . preg_replace('/[^a-zA-Z0-9_\\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
     $this->license = trim(wpum_get_option($this->item_shortname . '_license_key', ''));
     $this->includes();
     $this->hooks();
 }
/**
 * Validate recaptcha submission on login form
 *
 * @since 1.0.0
 * @return void
 */
function wpum_recaptcha_login_validation()
{
    if (!defined('DOING_AJAX') && isset($_SERVER['HTTP_REFERER']) && isset($_POST['log']) && isset($_POST['pwd'])) {
        // check what page the login attempt is coming from
        $referrer = $_SERVER['HTTP_REFERER'];
        // Verify we're not into the wp-login page
        if (!empty($referrer) && !strstr($referrer, 'wp-login') && !strstr($referrer, 'wp-admin')) {
            // Define the google's api url
            $url = 'https://www.google.com/recaptcha/api/siteverify';
            // Send form response to google's api
            $response = wp_remote_post($url, array('method' => 'POST', 'body' => array('secret' => wpum_get_option('recaptcha_secret_key'), 'response' => $_POST['g-recaptcha-response'], 'remoteip' => $_SERVER['REMOTE_ADDR'])));
            // Retrieve body of the response
            $api_response = json_decode(wp_remote_retrieve_body($response), true);
            // Display error within the form
            if (!$api_response['success']) {
                $url = add_query_arg(array('login' => false, 'captcha' => 'failed_captcha'), $referrer);
                wp_redirect($url);
                exit;
            }
        }
    }
}
Exemplo n.º 10
0
 * Email Header
 * @version     1.1.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
// For gmail compatibility, including CSS styles in head/body are stripped out therefore styles need to be inline. These variables contain rules which are added to the template inline. !important; is a gmail hack to prevent styles being stripped if it doesn't like something.
$body = "\n\tbackground-color: #f6f6f6;\n\tfont-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;\n";
$wrapper = "\n\twidth:100%;\n\t-webkit-text-size-adjust:none !important;\n\tmargin:0;\n\tpadding: 70px 0 70px 0;\n";
$template_container = "\n\tbox-shadow:0 0 0 1px #f3f3f3 !important;\n\tborder-radius:3px !important;\n\tbackground-color: #ffffff;\n\tborder: 1px solid #e9e9e9;\n\tborder-radius:3px !important;\n\tpadding: 20px;\n";
$template_header = "\n\tcolor: #00000;\n\tborder-top-left-radius:3px !important;\n\tborder-top-right-radius:3px !important;\n\tborder-bottom: 0;\n\tfont-weight:bold;\n\tline-height:100%;\n\ttext-align: center;\n\tvertical-align:middle;\n";
$body_content = "\n\tborder-radius:3px !important;\n\tfont-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;\n";
$body_content_inner = "\n\tcolor: #000000;\n\tfont-size:14px;\n\tfont-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;\n\tline-height:150%;\n\ttext-align:left;\n";
$header_content_h1 = "\n\tcolor: #000000;\n\tmargin:0;\n\tpadding: 28px 24px;\n\tdisplay:block;\n\tfont-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;\n\tfont-size:32px;\n\tfont-weight: 500;\n\tline-height: 1.2;\n";
$header_img = wpum_get_option('email_logo', '');
?>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title><?php 
echo get_bloginfo('name');
?>
</title>
	</head>
	<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" style="<?php 
echo $body;
?>
">
		<div style="<?php 
/**
 * Email template tag: recovery_url
 *
 * @param int $user_id
 * @param int $private_key
 * @return string url
 */
function wpum_email_tag_recovery_url($user_id, $private_key)
{
    $username = get_userdata($user_id);
    $username = esc_attr($username->user_login);
    $url = add_query_arg(array('password-reset' => true, 'key' => $private_key, 'login' => $username), get_permalink(wpum_get_option('password_recovery_page')));
    return esc_url_raw($url);
}
Exemplo n.º 12
0
/**
 * Checks if members can view profiles.
 *
 * @since 1.0.0
 * @return bool
 */
function wpum_members_can_view_profiles()
{
    $pass = false;
    if (wpum_get_option('members_can_view_profiles')) {
        $pass = true;
    }
    return $pass;
}
Exemplo n.º 13
0
/**
 * Loads the plugin frontend assets files
 *
 * @since 1.0.0
 * @return void
 */
function wpum_frontend_cssjs()
{
    $js_dir = WPUM_PLUGIN_URL . 'assets/js/';
    $css_dir = WPUM_PLUGIN_URL . 'assets/css/';
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    // Default URL
    $url = $css_dir . 'wp_user_manager_frontend' . $suffix . '.css';
    $file = 'wp_user_manager_frontend' . $suffix . '.css';
    $templates_dir = 'wpum/';
    $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()) . $templates_dir . $file;
    $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()) . $templates_dir . 'wp_user_manager_frontend.css';
    $parent_theme_style_sheet = trailingslashit(get_template_directory()) . $templates_dir . $file;
    $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()) . $templates_dir . 'wp_user_manager_frontend.css';
    $wpum_plugin_style_sheet = trailingslashit(wpum_get_templates_dir()) . $file;
    // Look in the child theme directory first, followed by the parent theme, followed by the WPUM core templates directory
    // Also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled.
    // This allows users to copy just wp_user_manager_frontend.css to their theme
    if (file_exists($child_theme_style_sheet) || !empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2))) {
        if (!empty($nonmin)) {
            $url = trailingslashit(get_stylesheet_directory_uri()) . $templates_dir . 'wp_user_manager_frontend.css';
        } else {
            $url = trailingslashit(get_stylesheet_directory_uri()) . $templates_dir . $file;
        }
    } elseif (file_exists($parent_theme_style_sheet) || !empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2))) {
        if (!empty($nonmin)) {
            $url = trailingslashit(get_template_directory_uri()) . $templates_dir . 'wp_user_manager_frontend.css';
        } else {
            $url = trailingslashit(get_template_directory_uri()) . $templates_dir . $file;
        }
    } elseif (file_exists($wpum_plugin_style_sheet) || file_exists($wpum_plugin_style_sheet)) {
        $url = trailingslashit(wpum_get_templates_url()) . $file;
    }
    // Styles & scripts registration
    wp_register_script('wpum-frontend-js', $js_dir . 'wp_user_manager' . $suffix . '.js', array('jquery'), WPUM_VERSION, true);
    wp_register_style('wpum-frontend-css', $url, WPUM_VERSION);
    // Enqueue everything
    wp_enqueue_script('jQuery');
    wp_enqueue_script('wpum-frontend-js');
    // Allows developers to disable the frontend css in case own file is needed.
    if (!defined('WPUM_DISABLE_CSS')) {
        wp_enqueue_style('wpum-frontend-css');
    }
    // Display password meter only if enabled
    if (wpum_get_option('display_password_meter_registration')) {
        wp_enqueue_script('password-strength-meter');
        wp_localize_script('password-strength-meter', 'pwsL10n', array('empty' => __('Strength indicator', 'wpum'), 'short' => __('Very weak', 'wpum'), 'bad' => __('Weak', 'wpum'), 'good' => _x('Medium', 'password strength', 'wpum'), 'strong' => __('Strong', 'wpum')));
    }
    // Frontend jS Settings
    wp_localize_script('wpum-frontend-js', 'wpum_frontend_js', array('ajax' => admin_url('admin-ajax.php'), 'checking_credentials' => __('Checking credentials...', 'wpum'), 'pwd_meter' => wpum_get_option('display_password_meter_registration'), 'disable_ajax' => wpum_get_option('disable_ajax')));
}
Exemplo n.º 14
0
    echo esc_url($value);
    ?>
" /></span>
	<?php 
} else {
    ?>
		<span class="wpum-uploaded-file-name"><code><?php 
    echo esc_html(basename($value));
    ?>
</code></span>
	<?php 
}
?>

	<?php 
if (!wpum_get_option('disable_ajax')) {
    ?>
	<a class="wpum-remove-uploaded-file" href="#" data-remove="<?php 
    echo esc_attr($field_name);
    ?>
">[<?php 
    _e('remove', 'wpum');
    ?>
]</a>
	<?php 
}
?>

	<input type="hidden" class="input-text" name="<?php 
echo esc_attr($name);
?>
Exemplo n.º 15
0
/**
 * Authenticate the user and decide which login method to use.
 *
 * @since 1.0.3
 * @param  string $user     user object
 * @param  string $username typed username
 * @param  string $password typed password
 * @return void Results of autheticating via wp_authenticate_username_password(), using the username found when looking up via email.
 */
function wpum_authenticate_login_method($user, $username, $password)
{
    // Get default login method
    $login_method = wpum_get_option('login_method', 'username');
    // Authenticate via email only
    if ($login_method == 'email') {
        if (is_a($user, 'WP_User')) {
            return $user;
        }
        if (!empty($username) && is_email($username)) {
            $user = get_user_by('email', $username);
            if (isset($user, $user->user_login, $user->user_status) && 0 == (int) $user->user_status) {
                $username = $user->user_login;
            }
            return wp_authenticate_username_password(null, $username, $password);
        }
    } else {
        if ($login_method == 'username_email') {
            if (is_a($user, 'WP_User')) {
                return $user;
            }
            $username = sanitize_user($username);
            if (!empty($username) && is_email($username)) {
                $user = get_user_by('email', $username);
                if (isset($user, $user->user_login, $user->user_status) && 0 == (int) $user->user_status) {
                    $username = $user->user_login;
                }
                return wp_authenticate_username_password(null, $username, $password);
            } else {
                return wp_authenticate_username_password(null, $username, $password);
            }
        }
    }
}
Exemplo n.º 16
0
include_once 'wp-user-manager.php';
global $wpdb;
// Delete post type contents
$wpum_post_types = array('wpum_directory');
foreach ($wpum_post_types as $post_type) {
    $items = get_posts(array('post_type' => $post_type, 'post_status' => 'any', 'numberposts' => -1, 'fields' => 'ids'));
    if ($items) {
        foreach ($items as $item) {
            wp_delete_post($item, true);
        }
    }
}
// Delete created pages
$wpum_pages = array('login_page', 'password_recovery_page', 'registration_page', 'account_page', 'profile_page');
foreach ($wpum_pages as $p) {
    $page = wpum_get_option($p, false);
    if ($page) {
        wp_delete_post($page, false);
    }
}
// Delete options
delete_option('wpum_settings');
delete_option('wpum_emails');
delete_option('wpum_permalink');
delete_option('wpum_custom_fields');
delete_option('wpum_version');
delete_option('wpum_version_upgraded_from');
delete_transient('_wpum_activation_redirect');
delete_option('wpum_activation_date');
// Remove all database tables
$wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "wpum_fields");
Exemplo n.º 17
0
 /**
  * Get the enabled email template
  *
  * @since 1.0.0
  */
 public function get_template()
 {
     if (!$this->template) {
         $this->template = wpum_get_option('email_template', 'none');
     }
     return apply_filters('wpum_email_template', $this->template);
 }
Exemplo n.º 18
0
	<?php 
if ($register == 'yes') {
    ?>
	<p class="wpum-register-url">
		<?php 
    echo apply_filters('wpum_registration_link_label', sprintf(__('Don\'t have an account? <a href="%s">Signup Now &raquo;</a>', 'wpum'), esc_url(get_permalink(wpum_get_option('registration_page')))));
    ?>
	</p>
	<?php 
}
?>

	<?php 
if ($password == 'yes') {
    ?>
	<p class="wpum-password-recovery-url">
		<a href="<?php 
    echo esc_url(get_permalink(wpum_get_option('password_recovery_page')));
    ?>
">
			<?php 
    echo apply_filters('wpum_password_link_label', __('Lost your password?', 'wpum'));
    ?>
		</a>
	</p>
	<?php 
}
?>

</div>
Exemplo n.º 19
0
/**
 * Get the login redirect url
 *
 * @since 1.0.0
 * @return mixed
 */
function wpum_get_login_redirect_url()
{
    $url = site_url($_SERVER['REQUEST_URI']);
    $selected_page = wpum_get_option('login_redirect');
    if ($selected_page) {
        $url = get_permalink($selected_page);
    }
    return esc_url($url);
}
 /**
  * Validate username field.
  *
  * @access public
  * @since 1.0.0
  * @return void
  */
 public static function validate_username($passed, $fields, $values)
 {
     $nickname = $values['register']['username'];
     if (wpum_get_option('exclude_usernames') && array_key_exists($nickname, wpum_get_disabled_usernames())) {
         return new WP_Error('nickname-validation-error', __('This nickname cannot be used.', 'wpum'));
     }
     // Check for nicknames if permalink structure requires unique nicknames.
     if (get_option('wpum_permalink') == 'nickname') {
         $current_user = wp_get_current_user();
         if ($username !== $current_user->user_nicename && wpum_nickname_exists($username)) {
             return new WP_Error('username-validation-error', __('This nickname cannot be used.', 'wpum'));
         }
     }
     return $passed;
 }
Exemplo n.º 21
0
/**
 * Returns the url where users are redirected after a successfull registration.
 *
 * @since 1.1.0
 * @return string redirect url
 */
function wpum_registration_redirect_url()
{
    $url = false;
    if (wpum_get_option('registration_redirect')) {
        $url = get_permalink(wpum_get_option('registration_redirect'));
    }
    return apply_filters('wpum_registration_redirect_url', $url);
}
Exemplo n.º 22
0
/**
 * Get the list of account fields formatted into an array.
 * The format of the array is used by the forms.
 *
 * @since 1.0.0
 * @return array - list of fields.
 */
function wpum_get_account_fields()
{
    // Get fields from the database
    $primary_group = WPUM()->field_groups->get_group_by('primary');
    $args = array('id' => $primary_group->id, 'array' => true, 'number' => -1, 'orderby' => 'field_order', 'order' => 'ASC');
    $data = WPUM()->fields->get_by_group($args);
    // Manipulate fields list into a list formatted for the forms API.
    $fields = array();
    // Loop through the found fields
    foreach ($data as $key => $field) {
        // Adjust field type parameter if no field type template is defined.
        switch ($field['type']) {
            case 'username':
            case 'nickname':
            case 'url':
                $field['type'] = 'text';
                break;
            case 'display_name':
                $field['type'] = 'select';
                break;
            case 'avatar':
                $field['type'] = 'file';
                break;
        }
        $fields[$field['meta']] = apply_filters('wpum_form_field', array('priority' => $field['field_order'], 'label' => stripslashes($field['name']), 'type' => $field['type'], 'meta' => $field['meta'], 'required' => $field['is_required'], 'description' => stripslashes($field['description']), 'placeholder' => apply_filters('wpum_profile_field_placeholder', null, $field), 'options' => apply_filters('wpum_profile_field_options', null, $field), 'value' => apply_filters('wpum_profile_field_value', null, $field)), $field['options']);
    }
    // Remove password field from here
    unset($fields['password']);
    // The username cannot be changed, let's remove that field since it's useless
    unset($fields['username']);
    // Remove the user avatar field if not enabled
    if (!wpum_get_option('custom_avatars')) {
        unset($fields['user_avatar']);
    }
    return apply_filters('wpum_get_account_fields', $fields);
}
Exemplo n.º 23
0
/**
 * Allows login form to redirect to an url specified into a query string.
 *
 * @since 1.1.0
 * @param  string $url url
 * @return string      url specified into the query string
 */
function wpum_login_redirect_detection($url)
{
    if (isset($_GET['redirect_to']) && $_GET['redirect_to'] !== '') {
        $url = urldecode($_GET['redirect_to']);
    } elseif (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] !== '' && !wpum_get_option('always_redirect')) {
        $url = $_SERVER['HTTP_REFERER'];
    } elseif (wpum_get_option('login_redirect')) {
        $url = get_permalink(wpum_get_option('login_redirect'));
    }
    return esc_url($url);
}
 /**
  * Handles resetting the user's password.
  *
  * @access public
  * @param object $user The user
  * @param string $new_pass New password for the user in plaintext
  * @return void
  */
 public static function change_password($user, $new_pass)
 {
     do_action('password_reset', $user, $new_pass);
     wp_set_password($new_pass, $user->ID);
     if (!wpum_get_option('disable_admin_password_recovery_email')) {
         wp_password_change_notification($user);
     }
 }
Exemplo n.º 25
0
/**
 * Adds markup to the login form.
 *
 * @since 1.1.0
 * @return void
 */
function wpumre_login_markup($content, $args)
{
    $content .= '<p class="wpum-recaptcha"><div class="g-recaptcha" data-sitekey="' . wpum_get_option('recaptcha_site_key') . '"></div></p>';
    return $content;
}