function qum_autologin_after_password_changed() { if (isset($_POST['action']) && $_POST['action'] == 'edit_profile') { if (isset($_POST['passw1']) && !empty($_POST['passw1']) && !empty($_POST['form_name'])) { /* all the error checking filters are defined in each field file so we need them here */ if (file_exists(QUM_PLUGIN_DIR . '/front-end/default-fields/default-fields.php')) { require_once QUM_PLUGIN_DIR . '/front-end/default-fields/default-fields.php'; } if (file_exists(QUM_PLUGIN_DIR . '/front-end/extra-fields/extra-fields.php')) { require_once QUM_PLUGIN_DIR . '/front-end/extra-fields/extra-fields.php'; } /* we get the form_name through $_POST so we can apply correctly the filter so we generate the correct fields in the current form */ $form_fields = apply_filters('qum_change_form_fields', get_option('qum_manage_fields'), array('form_type' => 'edit_profile', 'form_fields' => array(), 'form_name' => $_POST['form_name'], 'role' => '')); if (!empty($form_fields)) { /* check for errors in the form through the filters */ $output_field_errors = array(); foreach ($form_fields as $field) { $error_for_field = apply_filters('qum_check_form_field_' . Wordpress_Creation_Kit_QUM::wck_generate_slug($field['field']), '', $field, $_POST, 'edit_profile'); if (!empty($error_for_field)) { $output_field_errors[$field['id']] = '<span class="qum-form-error">' . $error_for_field . '</span>'; } } /* if we have no errors change the password */ if (empty($output_field_errors)) { $user_id = get_current_user_id(); wp_clear_auth_cookie(); /* set the new password for the user */ wp_set_password($_POST['passw1'], $user_id); // Here we calculate the expiration length of the current auth cookie and compare it to the default expiration. // If it's greater than this, then we know the user checked 'Remember Me' when they logged in. $logged_in_cookie = wp_parse_auth_cookie('', 'logged_in'); /** This filter is documented in wp-includes/pluggable.php */ $default_cookie_life = apply_filters('auth_cookie_expiration', 2 * DAY_IN_SECONDS, $user_id, false); $remember = $logged_in_cookie['expiration'] - time() > $default_cookie_life; wp_set_auth_cookie($user_id, $remember); } } } } }
/** * Function that saves the entries for single forms on posts(no options). It is hooke on the 'save_post' hook * It is executed on each WCK object instance so we need to restrict it on only the ones that are present for that post */ function wck_save_single_metabox($post_id, $post) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions if (!current_user_can('edit_page', $post_id)) { return $post_id; } /* only go through for metaboxes defined for this post type */ if (get_post_type($post_id) != $this->args['post_type']) { return $post_id; } if (!empty($_POST)) { /* for single metaboxes we save a hidden input that contains the meta_name attr as a key so we need to search for it */ foreach ($_POST as $request_key => $request_value) { if (strpos($request_key, '_wckmetaname_') !== false && strpos($request_key, '#wck') !== false) { /* found it so now retrieve the meta_name from the key formatted _wckmetaname_actuaname#wck */ $request_key = str_replace('_wckmetaname_', '', $request_key); $meta_name = str_replace('#wck', '', $request_key); /* we have it so go through only on the WCK object instance that has this meta_name */ if ($this->args['meta_name'] == $meta_name) { /* get the meta values from the $_POST and store them in an array */ $meta_values = array(); if (!empty($this->args['meta_array'])) { foreach ($this->args['meta_array'] as $meta_field) { /* in the $_POST the names for the fields are prefixed with the meta_name for the single metaboxes in case there are multiple metaboxes that contain fields wit hthe same name */ $single_field_name = $this->args['meta_name'] . '_' . Wordpress_Creation_Kit_QUM::wck_generate_slug($meta_field['title'], $meta_field); if (!empty($_POST[$single_field_name])) { /* checkbox needs to be stored as string not array */ if ($meta_field['type'] == 'checkbox') { $_POST[$single_field_name] = implode(', ', $_POST[$single_field_name]); } $meta_values[Wordpress_Creation_Kit_QUM::wck_generate_slug($meta_field['title'], $meta_field)] = $_POST[$single_field_name]; } else { $meta_values[Wordpress_Creation_Kit_QUM::wck_generate_slug($meta_field['title'], $meta_field)] = ''; } } } /* test if we have errors for the required fields */ $errors = self::wck_test_required($this->args['meta_array'], $meta_name, $meta_values, $post_id); if (!empty($errors)) { /* if we have errors then add them in the global. We do this so we get all errors from all single metaboxes that might be on that page */ global $wck_single_forms_errors; if (!empty($errors['errorfields'])) { foreach ($errors['errorfields'] as $key => $field_name) { $errors['errorfields'][$key] = $this->args['meta_name'] . '_' . $field_name; } } $wck_single_forms_errors[] = $errors; } else { /* no errors so we can save */ update_post_meta($post_id, $meta_name, array($meta_values)); /* handle unserialized fields */ if ($this->args['unserialize_fields']) { if (!empty($this->args['meta_array'])) { foreach ($this->args['meta_array'] as $meta_field) { update_post_meta($post_id, $meta_name . '_' . Wordpress_Creation_Kit_QUM::wck_generate_slug($meta_field['title'], $meta_field) . '_1', $_POST[$this->args['meta_name'] . '_' . Wordpress_Creation_Kit_QUM::wck_generate_slug($meta_field['title'], $meta_field)]); } } } } break; } } } } }
function qum_add_custom_field_values($global_request, $meta, $form_properties) { if (!empty($this->args['form_fields'])) { foreach ($this->args['form_fields'] as $field) { if (!empty($field['meta-name'])) { $posted_value = !empty($global_request[$field['meta-name']]) ? $global_request[$field['meta-name']] : ''; $meta[$field['meta-name']] = apply_filters('qum_add_to_user_signup_form_field_' . Wordpress_Creation_Kit_QUM::wck_generate_slug($field['field']), $posted_value, $field, $global_request); } } } return apply_filters('qum_add_to_user_signup_form_meta', $meta, $global_request); }
<?php /* @param string $meta Meta name. * @param array $details Contains the details for the field. * @param string $value Contains input value; * @param string $context Context where the function is used. Depending on it some actions are preformed.; * @return string $element input element html string. */ $element .= '<select name="' . $single_prefix . esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details)) . '" id="'; if (!empty($frontend_prefix)) { $element .= $frontend_prefix; } $element .= esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details)) . '" class="mb-select mb-field" >'; if (!empty($details['default-option']) && $details['default-option']) { $element .= '<option value="">' . __('...Choose', 'quickusermanager') . '</option>'; } $field_name = Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details); $options = ''; if (!empty($details['options'])) { $i = 0; foreach ($details['options'] as $option) { if (strpos($option, '%') === false) { $label = $option; if (!empty($details['values'])) { $value_attr = $details['values'][$i]; } else { $value_attr = $option; } } else { $option_parts = explode('%', $option); if (!empty($option_parts)) { if (empty($option_parts[0]) && count($option_parts) == 3) {
/** * Create a user. * * @param string $user_name The new user's login name. * @param string $password The new user's password. * @param string $email The new user's email address. * @return mixed Returns false on failure, or int $user_id on success */ function qum_create_user($user_name, $password, $email) { if (is_email($user_name)) { $user_name = apply_filters('qum_generated_random_username', Wordpress_Creation_Kit_QUM::wck_generate_slug(trim($user_name)), $user_name); } else { $user_name = preg_replace('/\\s+/', '', sanitize_user($user_name, true)); } $user_id = wp_create_user($user_name, $password, $email); if (is_wp_error($user_id)) { return false; } // Newly created users have no roles or caps until they are added to a blog. delete_user_option($user_id, 'capabilities'); delete_user_option($user_id, 'user_level'); do_action('qum_new_user', $user_id); return $user_id; }
function qum_front_end_login($atts) { extract(shortcode_atts(array('display' => true, 'redirect' => '', 'redirect_url' => '', 'register_url' => '', 'lostpassword_url' => ''), $atts)); $qum_generalSettings = get_option('qum_general_settings'); if (!is_user_logged_in()) { // set up the form arguments $form_args = array('echo' => false, 'id_submit' => 'qum-submit'); //Add support for "redirect_url" parameter for Login shortcode (will do the same thing as "redirect" - for consistency with Register, Edit Profile shortcodes) if (!empty($redirect_url)) { $redirect = $redirect_url; } // maybe set up the redirect argument if (empty($redirect)) { if (QUICK_USER_MANAGER == 'Quick User Manager Pro') { $qum_module_settings = get_option('qum_module_settings'); if ($qum_module_settings['qum_customRedirect'] == 'show') { //check to see if the redirect location is not an empty string and is activated $login_redirect_settings = get_option('customRedirectSettings'); // set up the redirect argument to our redirect page if (trim($login_redirect_settings['afterLoginTarget']) != '' && $login_redirect_settings['afterLogin'] == 'yes') { $redirect_to = trim($login_redirect_settings['afterLoginTarget']); if (qum_check_missing_http($redirect_to)) { $redirect_to = 'http://' . $redirect_to; } $form_args['redirect'] = $redirect_to; } } } } else { $form_args['redirect'] = trim($redirect); } // change the label argument for username is login with email is enabled if (isset($qum_generalSettings['loginWith']) && $qum_generalSettings['loginWith'] == 'email') { $form_args['label_username'] = __('Email', 'quickusermanager'); } // change the label argument for username on login with username or email when Username and Email is enabled if (isset($qum_generalSettings['loginWith']) && $qum_generalSettings['loginWith'] == 'usernameemail') { $form_args['label_username'] = __('Username or Email', 'quickusermanager'); } // initialize our form variable $login_form = ''; // display our login errors if (isset($_GET['loginerror']) || isset($_POST['loginerror'])) { $loginerror = isset($_GET['loginerror']) ? $_GET['loginerror'] : $_POST['loginerror']; $loginerror = '<p class="qum-error">' . urldecode(base64_decode($loginerror)) . '</p><!-- .error -->'; if (isset($_GET['request_form_location'])) { if ($_GET['request_form_location'] == 'widget' && !in_the_loop()) { $login_form .= $loginerror; } elseif ($_GET['request_form_location'] == 'page' && in_the_loop()) { $login_form .= $loginerror; } } } // build our form $login_form .= '<div id="qum-login-wrap" class="qum-user-forms">'; $form_args['lostpassword_url'] = $lostpassword_url; $login_form .= wp_login_form(apply_filters('qum_login_form_args', $form_args)); if (!empty($register_url) || !empty($lostpassword_url)) { $login_form .= '<p class="login-register-lost-password">'; $i = 0; if (!empty($register_url)) { if (qum_check_missing_http($register_url)) { $register_url = "http://" . $register_url; } $login_form .= '<a href="' . esc_url($register_url) . '">' . apply_filters('qum_login_register_text', __('Register', 'quickusermanager')) . '</a>'; $i++; } if (!empty($lostpassword_url)) { if ($i != 0) { $login_form .= ' | '; } if (qum_check_missing_http($lostpassword_url)) { $lostpassword_url = "http://" . $lostpassword_url; } $login_form .= '<a href="' . esc_url($lostpassword_url) . '">' . apply_filters('qum_login_lostpass_text', __('Lost your password?', 'quickusermanager')) . '</a>'; } $login_form .= '</p>'; } $login_form .= '</div>'; return $login_form; } else { $user_ID = get_current_user_id(); $qum_user = get_userdata($user_ID); if (isset($qum_generalSettings['loginWith']) && $qum_generalSettings['loginWith'] == 'email') { $display_name = $qum_user->user_email; } elseif ($qum_user->display_name !== '') { $display_name = $qum_user->user_login; } else { $display_name = $qum_user->display_name; } if (isset($qum_generalSettings['loginWith']) && $qum_generalSettings['loginWith'] == 'usernameemail') { if ($qum_user->user_login == Wordpress_Creation_Kit_QUM::wck_generate_slug(trim($qum_user->user_email))) { $display_name = $qum_user->user_email; } elseif ($qum_user->display_name !== '') { $display_name = $qum_user->user_login; } else { $display_name = $qum_user->display_name; } } $logged_in_message = '<p class="qum-alert">'; $user_url = '<a href="' . ($authorPostsUrl = get_author_posts_url($qum_user->ID) . '" class="qum-author-url" title="' . $display_name . '">' . $display_name . '</a>'); $logout_url = '<a href="' . wp_logout_url($redirectTo = qum_curpageurl()) . '" class="qum-logout-url" title="' . __('Log out of this account', 'quickusermanager') . '">' . __('Log out', 'quickusermanager') . ' »</a>'; $logged_in_message .= sprintf(__('%1$s', 'quickusermanager'), $logout_url); $logged_in_message .= '</p><!-- .qum-alert-->'; return apply_filters('qum_login_message', $logged_in_message, $qum_user->ID, $display_name); } }
<?php /* @param string $meta Meta name. * @param array $details Contains the details for the field. * @param string $value Contains input value; * @param string $context Context where the function is used. Depending on it some actions are preformed.; * @return string $element input element html string. */ $element .= '<textarea name="' . $single_prefix . esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details)) . '" id="'; if (!empty($frontend_prefix)) { $element .= $frontend_prefix; } $element .= esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details)) . '" style="vertical-align:top;" class="mb-textarea mb-field">' . esc_html($value) . '</textarea>';
<?php /* @param string $meta Meta name. * @param array $details Contains the details for the field. * @param string $value Contains input value; * @param string $context Context where the function is used. Depending on it some actions are preformed.; * @return string $element input element html string. */ $args = apply_filters('wck-user-select-args', array('orderby' => 'display_name')); $user_query = new WP_User_Query($args); if (!empty($user_query->results)) { $element .= '<select name="' . $single_prefix . esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details)) . '" id="'; if (!empty($frontend_prefix)) { $element .= $frontend_prefix; } $element .= esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details)) . '" class="mb-user-select mb-field" >'; $element .= '<option value="">' . __('...Choose', 'quickusermanager') . '</option>'; foreach ($user_query->results as $user) { $element .= '<option value="' . esc_attr($user->ID) . '" ' . selected($user->ID, $value, false) . ' >' . esc_html($user->display_name) . '</option>'; } $element .= '</select>'; }
<?php /* @param string $meta Meta name. * @param array $details Contains the details for the field. * @param string $value Contains input value; * @param string $context Context where the function is used. Depending on it some actions are preformed.; * @return string $element input element html string. */ $element .= '<textarea name="' . $single_prefix . esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details)) . '" style="vertical-align:top;width:400px;height:200px" class="mb-textarea mb-field ' . esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details)) . '">' . esc_html($value) . '</textarea>'; $element .= '<script type="text/javascript">jQuery( function(){ if ( typeof wckInitTinyMCE == "function" ) wckInitTinyMCE("' . Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details) . '")});</script>';
} } else { $option_parts = explode('%', $option); if (!empty($option_parts)) { if (empty($option_parts[0]) && count($option_parts) == 3) { $label = $option_parts[1]; $value_attr = $option_parts[2]; if (in_array($option_parts[2], $values)) { $found = true; } } } } $element .= '<div><label><input type="checkbox" name="' . $single_prefix . esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details)); if ($this->args['single']) { $element .= '[]'; } $element .= '" id="'; if (!empty($frontend_prefix)) { $element .= $frontend_prefix; } /* since the slug below is generated from the value as well we need to determine here if we have a slug or not and not let the wck_generate_slug() function do that */ if (!empty($details['slug'])) { $slug_from = $details['slug']; } else { $slug_from = $details['title']; } $element .= esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($slug_from . '_' . $value_attr)) . '" value="' . esc_attr($value_attr) . '" ' . checked($found, true, false) . 'class="mb-checkbox mb-field" />' . esc_html($label) . '</label></div>'; } $element .= '</div>'; }
<?php /* @param string $meta Meta name. * @param array $details Contains the details for the field. * @param string $value Contains input value; * @param string $context Context where the function is used. Depending on it some actions are preformed.; * @return string $element input element html string. */ $element .= '<input type="text" name="' . $single_prefix . esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details)) . '" id="'; if (!empty($frontend_prefix)) { $element .= $frontend_prefix; } $element .= esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details)) . '"'; if (!empty($details['readonly']) && $details['readonly']) { $element .= 'readonly="readonly"'; } $element .= ' value="' . esc_attr($value) . '" class="mb-text-input mb-field"/>';
$element .= '<div id="' . esc_attr($upload_info_div_id) . '_info_container" class="upload-field-details" data-attachment_id="' . $value . '">'; $element .= '<div class="file-thumb">'; $element .= "<a href='{$attachment_url}' target='_blank' class='wck-attachment-link'>" . $thumbnail . "</a>"; $element .= '</div>'; $element .= '<p><span class="file-name">'; $element .= $file_name; $element .= '</span><span class="file-type">'; $element .= $file_type; $element .= '</span>'; if (!empty($value)) { $element .= '<span class="wck-remove-upload">' . __('Remove', 'core') . '</span>'; } $element .= '</p></div>'; } } $element .= '<a href="#" class="button wck_upload_button" id="upload_' . esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details)) . '_button" data-uploader_title="' . $details['title'] . '" data-uploader_button_text="Select Files" data-upload_input="' . esc_attr($upload_input_id) . '" '; if (is_user_logged_in()) { $element .= 'data-uploader_logged_in="true"'; } if (!empty($post_id)) { $element .= ' data-post_id="' . $post_id . '"'; } if (!empty($details['multiple_upload'])) { if ($details['multiple_upload'] == 'true') { $element .= ' data-multiple_upload="true"'; } else { $element .= ' data-multiple_upload="false"'; } } if (!empty($details['attach_to_post'])) { if ($details['attach_to_post'] == true) {
/** * Function that adds a custom class to the existing element * * @since v.1.0 * * @param string $element_class - the new class name * @param string $meta - the name of the meta * @param array $results * @param integer $element_id - the ID of the element * * @return string */ function qum_element_class($element_class, $meta, $results, $element_id) { $qum_element_type = Wordpress_Creation_Kit_QUM::wck_generate_slug($results[$element_id]["field"]); return "class='element_type_{$qum_element_type} added_fields_list'"; }
<?php /* @param string $meta Meta name. * @param array $details Contains the details for the field. * @param string $value Contains input value; * @param string $context Context where the function is used. Depending on it some actions are preformed.; * @return string $element input element html string. */ $element .= '<input type="text" name="' . $single_prefix . esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details)) . '" id="'; if (!empty($frontend_prefix)) { $element .= $frontend_prefix; } $element .= esc_attr(Wordpress_Creation_Kit_QUM::wck_generate_slug($details['title'], $details)) . '" value="' . esc_attr($value) . '" class="mb-datepicker mb-field"/>'; $element .= '<script type="text/javascript">jQuery( function(){jQuery(".mb-datepicker").datepicker({' . apply_filters('wck-datepicker-args', 'dateFormat : "dd-mm-yy",changeMonth: true,changeYear: true') . '})});</script>';