예제 #1
0
파일: core.php 프로젝트: pab44/pab44
 /**
  * Handles user password change (not reset).
  *
  * @since 2.1.0
  *
  * @global int $user_ID The WordPress user ID.
  *
  * @return string The value for $wpmem->regchk
  */
 function wpmem_change_password()
 {
     global $user_ID;
     if (isset($_POST['formsubmit'])) {
         $is_error = false;
         $pass1 = wpmem_get('pass1', false);
         //trim( $_POST['pass1'] );
         $pass2 = wpmem_get('pass2', false);
         //trim( $_POST['pass2'] );
         // Check for both fields being empty.
         $is_error = !$pass1 && !$pass2 ? "pwdchangempty" : $is_error;
         // Make sure the fields match.
         $is_error = $pass1 != $pass2 ? "pwdchangerr" : $is_error;
         /**
          * Filters the password change error.
          *
          * @since 3.1.5
          *
          * @param string $is_error
          * @param int    $user_ID  The user's numeric ID.
          * @param string $pass1    The user's new plain text password.
          */
         $is_error = apply_filters('wpmem_pwd_change_error', $is_error, $user_ID, $pass1);
         if ($is_error) {
             return $is_error;
         }
         // Update user password.
         wp_update_user(array('ID' => $user_ID, 'user_pass' => $pass1));
         /**
          * Fires after password change.
          *
          * @since 2.9.0
          * @since 3.0.5 Added $pass1 to arguments passed.
          *
          * @param int    $user_ID The user's numeric ID.
          * @param string $pass1   The user's new plain text password.
          */
         do_action('wpmem_pwd_change', $user_ID, $pass1);
         return "pwdchangesuccess";
     }
     return;
 }
예제 #2
0
파일: tab-options.php 프로젝트: pab44/pab44
/**
 * Updates the plugin options.
 *
 * @since 2.8.0
 *
 * @global object $wpmem The WP_Members object.
 * @return string        The options updated message.
 */
function wpmem_update_options()
{
    global $wpmem;
    // Check nonce.
    check_admin_referer('wpmem-update-settings');
    $wpmem_settings_msurl = $_POST['wpmem_settings_mspage'] == 'use_custom' ? $_POST['wpmem_settings_msurl'] : '';
    $wpmem_settings_mspage = $_POST['wpmem_settings_mspage'] == 'use_custom' ? '' : $_POST['wpmem_settings_mspage'];
    if ($wpmem_settings_msurl != wpmem_use_ssl() && $wpmem_settings_msurl != 'use_custom' && !$wpmem_settings_mspage) {
        $msurl = trim($wpmem_settings_msurl);
    } else {
        $msurl = $wpmem_settings_mspage;
    }
    $wpmem_settings_regurl = $_POST['wpmem_settings_regpage'] == 'use_custom' ? $_POST['wpmem_settings_regurl'] : '';
    $wpmem_settings_regpage = $_POST['wpmem_settings_regpage'] == 'use_custom' ? '' : $_POST['wpmem_settings_regpage'];
    if ($wpmem_settings_regurl != wpmem_use_ssl() && $wpmem_settings_regurl != 'use_custom' && !$wpmem_settings_regpage) {
        $regurl = trim($wpmem_settings_regurl);
    } else {
        $regurl = $wpmem_settings_regpage;
    }
    $wpmem_settings_logurl = $_POST['wpmem_settings_logpage'] == 'use_custom' ? $_POST['wpmem_settings_logurl'] : '';
    $wpmem_settings_logpage = $_POST['wpmem_settings_logpage'] == 'use_custom' ? '' : $_POST['wpmem_settings_logpage'];
    if ($wpmem_settings_logurl != wpmem_use_ssl() && $wpmem_settings_logurl != 'use_custom' && !$wpmem_settings_logpage) {
        $logurl = trim($wpmem_settings_logurl);
    } else {
        $logurl = $wpmem_settings_logpage;
    }
    $wpmem_settings_cssurl = $_POST['wpmem_settings_cssurl'];
    $cssurl = $wpmem_settings_cssurl != wpmem_use_ssl() ? trim($wpmem_settings_cssurl) : '';
    $wpmem_settings_style = isset($_POST['wpmem_settings_style']) ? $_POST['wpmem_settings_style'] : false;
    $wpmem_newsettings = array('version' => WPMEM_VERSION, 'notify' => wpmem_get('wpmem_settings_notify', 0), 'mod_reg' => wpmem_get('wpmem_settings_moderate', 0), 'captcha' => wpmem_get('wpmem_settings_captcha', 0), 'use_exp' => wpmem_get('wpmem_settings_time_exp', 0), 'use_trial' => wpmem_get('wpmem_settings_trial', 0), 'warnings' => wpmem_get('wpmem_settings_ignore_warnings', 0), 'user_pages' => array('profile' => $msurl ? $msurl : '', 'register' => $regurl ? $regurl : '', 'login' => $logurl ? $logurl : ''), 'cssurl' => $cssurl ? $cssurl : '', 'style' => $wpmem_settings_style, 'attrib' => wpmem_get('attribution', 0));
    // Build an array of post types
    $post_arr = array('post', 'page');
    if (isset($wpmem->post_types)) {
        $wpmem_newsettings['post_types'] = $wpmem->post_types;
        foreach ($wpmem_newsettings['post_types'] as $key => $val) {
            $post_arr[] = $key;
        }
    }
    // Leave form tag settings alone.
    if (isset($wpmem->form_tags)) {
        $wpmem_newsettings['form_tags'] = $wpmem->form_tags;
    }
    // Leave email settings alone.
    if (isset($wpmem->email)) {
        $wpmem_newsettings['email'] = $wpmem->email;
    }
    // Get settings for blocking, excerpts, show login, and show registration for posts, pages, and custom post types.
    $option_group_array = array('block', 'show_excerpt', 'show_login', 'show_reg', 'autoex');
    foreach ($option_group_array as $option_group_item) {
        $arr = array();
        foreach ($post_arr as $post_type) {
            $post_var = 'wpmem_' . $option_group_item . '_' . $post_type;
            if ($option_group_item == 'autoex') {
                // Auto excerpt is an array.
                $arr[$post_type]['enabled'] = isset($_POST[$post_var]) ? $_POST[$post_var] : 0;
                $arr[$post_type]['length'] = isset($_POST[$post_var]) ? $_POST[$post_var . '_len'] == '' ? 0 : $_POST[$post_var . '_len'] : '';
            } else {
                // All other settings are 0|1.
                $arr[$post_type] = isset($_POST[$post_var]) ? $_POST[$post_var] : 0;
            }
        }
        $wpmem_newsettings[$option_group_item] = $arr;
    }
    /*
     * If we are setting registration to be moderated, 
     * check to see if the current admin has been 
     * activated so they don't accidentally lock themselves
     * out later.
     */
    if (isset($_POST['wpmem_settings_moderate']) == 1) {
        global $current_user;
        wp_get_current_user();
        $user_ID = $current_user->ID;
        update_user_meta($user_ID, 'active', 1);
    }
    wpmem_admin_new_settings($wpmem_newsettings);
    return __('WP-Members settings were updated', 'wp-members');
}
예제 #3
0
파일: shortcodes.php 프로젝트: pab44/pab44
/**
 * Function to handle field shortcodes [wpmem_field].
 *
 * Shortcode to display the data for a given user field. Requires
 * that a field meta key be passed as an attribute.  Can either of
 * the following:
 * - [wpmem_field field="meta_key"]
 * - [wpmem_field meta_key] 
 *
 * Other attributes:
 *
 * - id (numeric user ID or "get" to retrieve uid from query string.
 * - underscores="true" strips underscores from the displayed value.
 * - display="raw" displays the stored value for dropdowns, radios, files.
 * - size(thumbnail|medium|large|full|w,h): image field only.
 *
 * @since 3.1.2
 * @since 3.1.4 Changed to display value rather than stored value for dropdown/multicheck/radio.
 * @since 3.1.5 Added display attribute, meta key as a direct attribute, and image/file display.
 *
 * @global object $wpmem   The WP_Members object.
 * @param  array  $atts    Shortcode attributes.
 * @param  string $content Any content passed with the shortcode (default:null).
 * @param  string $tag     The shortcode tag (wpmem_form).
 * @return string $content Content to return.
 */
function wpmem_sc_fields($atts, $content = null, $tag)
{
    // What field?
    $field = isset($atts[0]) ? $atts[0] : $atts['field'];
    // What user?
    if (isset($atts['id'])) {
        $the_ID = $atts['id'] == 'get' ? wpmem_get('uid', '', 'get') : $atts['id'];
    } else {
        $the_ID = get_current_user_id();
    }
    $user_info = get_userdata($the_ID);
    // If there is userdata.
    if ($user_info) {
        global $wpmem;
        $field_type = isset($wpmem->fields[$field]['type']) ? $wpmem->fields[$field]['type'] : 'native';
        $result = $user_info->{$field};
        // Handle select, multiple select, multiple checkbox, and radio groups.
        $array_fields = array('select', 'multiselect', 'multicheckbox', 'radio');
        if (!isset($atts['options']) && in_array($field_type, $array_fields)) {
            $result = isset($atts['display']) && 'raw' == $atts['display'] ? $user_info->{$field} : $wpmem->fields[$field]['options'][$user_info->{$field}];
        }
        // Handle file/image fields.
        if (isset($field_type) && ('file' == $field_type || 'image' == $field_type)) {
            if (isset($atts['display']) && 'raw' == $atts['display']) {
                $result = $user_info->{$field};
            } else {
                if ('file' == $field_type) {
                    $attachment_url = wp_get_attachment_url($user_info->{$field});
                    $result = $attachment_url ? '<a href="' . esc_url($attachment_url) . '">' . get_the_title($user_info->{$field}) . '</a>' : '';
                } else {
                    $size = 'thumbnail';
                    if (isset($atts['size'])) {
                        $sizes = array('thumbnail', 'medium', 'large', 'full');
                        $size = !in_array($atts['size'], $sizes) ? explode(",", $atts['size']) : $atts['size'];
                    }
                    $image = wp_get_attachment_image_src($user_info->{$field}, $size);
                    $result = $image ? '<img src="' . esc_url($image[0]) . '" width="' . esc_attr($image[1]) . '" height="' . esc_attr($image[2]) . '" />' : '';
                }
            }
            return do_shortcode($result);
        }
        // Remove underscores from value if requested (default: on).
        if (isset($atts['underscores']) && 'off' == $atts['underscores'] && $user_info) {
            $result = str_replace('_', ' ', $result);
        }
        $content = $content ? $result . $content : $result;
        return do_shortcode(htmlspecialchars($content));
    }
    return;
}
예제 #4
0
파일: api.php 프로젝트: pab44/pab44
/**
 * Checks the current tab being displayed in the admin panel.
 *
 * @since 3.1.4
 *
 * @param  string $tab The tab slug.
 * @return bool
 */
function wpmem_is_tab($tab)
{
    return $tab == wpmem_get('tab', false, 'get') ? true : false;
}
예제 #5
0
 /**
  * Get the current form.
  *
  * @since 3.1.2
  *
  * @todo Work on multi-form project for 3.1.2
  */
 function get_form($form = 'default')
 {
     /*
     $current_form = ( isset( $_GET['form'] ) ) ? $_GET['form'] : $form;
     $wpmem_forms = get_option( 'wpmembers_forms' );
     $fields = $wpmem_forms[ $current_form ];
     $this->current_form = $current_form;
     $this->current_form_fields = $fields;
     */
     $current_form = wpmem_get('form', $form, 'get');
     //( isset( $_GET['form'] ) ) ? $_GET['form'] : $form;
     $this->current_form = $current_form;
     global $wpmem;
     // Add numeric array form fields as associative
     foreach ($wpmem->fields as $field) {
         $wpmem->fields[$field[2]] = $field;
     }
     $this->current_form_fields = $wpmem->fields;
 }
예제 #6
0
파일: api.php 프로젝트: pab44/pab44
/**
 * Compares wpmem_reg_page value with the register page URL. 
 *
 * @since 3.1.4
 *
 * @param  string|int $check_page
 * @return bool
 */
function wpmem_is_reg_page($check)
{
    if (!is_int($check)) {
        global $wpdb;
        $sql = "SELECT ID FROM {$wpdb->posts} WHERE post_name = '{$check}' AND post_status = 'publish' LIMIT 1";
        $arr = $wpdb->get_results($sql, ARRAY_A);
        $check = $arr[0]['ID'];
    }
    $reg_page = wpmem_get('wpmem_reg_page');
    $check_page = get_permalink($check);
    return $check_page == $reg_page ? true : false;
}