function userpro_get_avatar($avatar, $id_or_email, $size, $default, $alt = '')
{
    global $userpro;
    require_once userpro_path . 'lib/BFI_Thumb.php';
    if (isset($id_or_email->user_id)) {
        $id_or_email = $id_or_email->user_id;
    } elseif (is_email($id_or_email)) {
        $user = get_user_by('email', $id_or_email);
        $id_or_email = $user->ID;
    }
    if ($id_or_email && userpro_profile_data('profilepicture', $id_or_email)) {
        $url = $userpro->file_uri(userpro_profile_data('profilepicture', $id_or_email), $id_or_email);
        $params = array('width' => $size, 'height' => $size, 'quality' => 100);
        $crop = bfi_thumb(get_site_url() . (strpos($url, "http") !== false ? urlencode($url) : $url), $params);
        $return = '<img src="' . $crop . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="modified avatar" />';
    } else {
        if ($id_or_email && userpro_profile_data('gender', $id_or_email)) {
            $gender = strtolower(userpro_profile_data('gender', $id_or_email));
        } else {
            $gender = 'male';
            // default gender
        }
        $userpro_default = userpro_url . 'img/default_avatar_' . $gender . '.jpg';
        $return = '<img src="' . $userpro_default . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="default avatar" />';
    }
    if (userpro_profile_data('profilepicture', $id_or_email) != '') {
        return $return;
    } else {
        if (userpro_get_option('use_default_avatars') == 1) {
            return $avatar;
        } else {
            return $return;
        }
    }
}
function userpro_before_form_submit($args)
{
    global $userpro;
    extract($args);
    if ($args['template'] == 'register' && userpro_get_option('terms_agree') == 1) {
        ?>
			
			<div class="userpro-column">
				<div class="userpro-field userpro-maxwidth" data-required="1" data-required_msg="<?php 
        _e('You must accept our terms and conditions', 'userpro');
        ?>
">
					<div class="userpro-input">
					
						<div class='userpro-checkbox-wrap'>
							<label class='userpro-checkbox full'>
								<span></span>
								<input type='checkbox' name='terms' id="terms" /><?php 
        echo html_entity_decode(userpro_get_option('terms_agree_text'));
        ?>
							</label>
						</div>
						
					</div>
				</div>
			</div><div class="userpro-clear"></div>
			
			<?php 
    }
}
Exemple #3
0
function userpro_fields_validation($errors, $form)
{
    global $userpro;
    $phonefields = userpro_get_option('phonefields');
    if (!$phonefields) {
        $phonefields = array('');
    } else {
        $phonefields = explode(',', $phonefields);
    }
    if (userpro_get_option('max_field_length_active')) {
        $max_field_length_include = userpro_get_option('max_field_length_include');
        if ($max_field_length_include != '') {
            $max_field_length_include = explode(',', $max_field_length_include);
        } else {
            $max_field_length_include = array('');
        }
    }
    // validate form
    foreach ($form as $k => $v) {
        if ($userpro->field_exists($k) && in_array($k, $phonefields) && $v != '' && !preg_match(userpro_get_option('phonefields_regex'), $v)) {
            $errors[$k] = __('Please enter a correct phone number', 'userpro');
        }
        if (isset($max_field_length_include)) {
            if ($userpro->field_exists($k) && $userpro->field_type($k) == 'text' && $v != '' && strlen($v) > userpro_get_option('max_field_length') && $userpro->field_label($k) && in_array($k, $max_field_length_include)) {
                $errors[$k] = sprintf(__('%s must not exceed %s characters', 'userpro'), $userpro->field_label($k), userpro_get_option('max_field_length'));
            }
        }
    }
    return $errors;
}
function userpro_get_avatar($avatar, $id_or_email, $size, $default, $alt = '')
{
    global $userpro;
    if (isset($id_or_email->user_id)) {
        $id_or_email = $id_or_email->user_id;
    } elseif (is_email($id_or_email)) {
        $user = get_user_by('email', $id_or_email);
        $id_or_email = $user->ID;
    }
    if ($id_or_email && userpro_profile_data('profilepicture', $id_or_email)) {
        $url = $userpro->file_uri(userpro_profile_data('profilepicture', $id_or_email));
        $crop = userpro_url . "lib/timthumb.php?src=" . $url . "&amp;w={$size}&amp;h={$size}&amp;a=t&amp;q=100";
        $return = '<img src="' . $crop . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="modified avatar" />';
    } else {
        if ($id_or_email && userpro_profile_data('gender', $id_or_email)) {
            $gender = strtolower(userpro_profile_data('gender', $id_or_email));
        } else {
            $gender = 'male';
            // default gender
        }
        $userpro_default = userpro_url . 'img/default_avatar_' . $gender . '.jpg';
        $return = '<img src="' . $userpro_default . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="default avatar" />';
    }
    if (userpro_profile_data('profilepicture', $id_or_email) != '') {
        return $return;
    } else {
        if (userpro_get_option('use_default_avatars') == 1) {
            return $avatar;
        } else {
            return $return;
        }
    }
}
function userpro_remove_admin_bar()
{
    if (!current_user_can('manage_options') && !is_admin()) {
        if (userpro_get_option('hide_admin_bar')) {
            show_admin_bar(false);
        }
    }
}
Exemple #6
0
function userpro_admin_users_badges($value, $column_name, $user_id)
{
    global $userpro;
    $user = get_userdata($user_id);
    if (userpro_get_option('backend_users_change')) {
        if ('userpro_username' == $column_name) {
            $res = '<div class="upadmin-avatar">' . get_avatar($user_id, 40) . '</div>';
            $res .= '<strong><a href="' . $userpro->permalink($user_id) . '" target="_blank" title="' . __('View Profile', 'userpro') . '">' . $user->user_login . '</a></strong><br />';
            $res .= '<span class="upadmin-small-name">(' . userpro_profile_data('display_name', $user_id) . ')</span>';
            $res .= '<div class="row-actions"><span class="edit"><a href="' . $userpro->permalink($user_id, 'edit') . '" target="_blank">' . __('Edit Profile', 'userpro') . '</a></span></div>';
            return $res;
        }
    }
    if ('userpro_admin_badges' == $column_name) {
        $res = userpro_show_badges($user_id, true);
        return $res;
    }
    if ('userpro_verify' == $column_name) {
        $res = '<div class="upadmin-verify-v2">';
        if ($userpro->get_verified_status($user_id) == 0) {
            $res .= '<a href="#" class="button upadmin-verify-u" data-user="******">' . userpro_get_badge('unverified') . '</a>';
        } else {
            if (userpro_is_admin($user_id)) {
                $res .= '<a href="#" class="button button-primary upadmin-unverify-u" data-user="******">' . userpro_get_badge('verified') . '</a>';
            } else {
                $res .= '<a href="#" class="button button-primary upadmin-unverify-u" data-user="******">' . userpro_get_badge('verified') . '</a>';
            }
        }
        if ($userpro->get_verified_status($user_id) == 0) {
            if ($userpro->invited_to_verify($user_id)) {
                $res .= '&nbsp;&nbsp;' . __('Invitation sent!', 'userpro');
            } else {
                $res .= '<a href="#" class="button upadmin-invite-u" data-user="******">' . __('Verified Invite', 'userpro') . '</a>';
            }
        }
        $res .= '</div>';
        return $res;
    }
    if ('block_users' == $column_name) {
        $res = '<div class="upadmin-block-v2">';
        if ($userpro->get_account_status($user_id) == 0) {
            $res .= '<a href="#" class="button upadmin-block-u" data-user="******">' . userpro_get_badge('unblocked') . '</a>';
        } else {
            if (userpro_is_admin($user_id)) {
                $res .= '<a href="#" class="button upadmin-unblock-u" data-user="******">' . userpro_get_badge('blocked') . '</a>';
            } else {
                $res .= '<a href="#" class="button upadmin-unblock-u" data-user="******">' . userpro_get_badge('blocked') . '</a>';
            }
        }
        if ($userpro->get_account_status($user_id) == 1) {
            $res .= '<span class="button" data-user="******">' . __('Account Blocked', 'userpro') . '</span>';
        }
        $res .= '</div>';
        $res .= '</div>';
        return $res;
    }
    return $value;
}
function userpro_register_redirect_uri()
{
    global $userpro;
    $possible = userpro_get_option('register_redirect_users');
    if ($possible == 1) {
        return $userpro->permalink(0, 'register');
    }
    if ($possible == 2) {
        return userpro_get_option('register_redirect_users_url');
    }
}
function userpro_remove_admin_bar()
{
    global $userpro;
    if (!current_user_can('manage_options') && !is_admin()) {
        if (userpro_get_option('hide_admin_bar')) {
            if (userpro_get_option('allow_dashboard_for_these_roles') && userpro_is_logged_in() && $userpro->user_role_in_array(get_current_user_id(), explode(',', userpro_get_option('allow_dashboard_for_these_roles')))) {
            } else {
                show_admin_bar(false);
            }
        }
    }
}
function userpro_unverify_verified_account($form, $user_id)
{
    global $userpro;
    // validate display name change
    if (!userpro_is_admin($user_id) && userpro_get_option('unverify_on_namechange') && $userpro->get_verified_status($user_id) == 1 && !current_user_can('manage_options')) {
        if (isset($form['display_name'])) {
            $old_displayname = userpro_profile_data('display_name', $user_id);
            $new_displayname = $form['display_name'];
            if ($new_displayname != $old_displayname) {
                $userpro->unverify($user_id);
            }
        }
    }
}
Exemple #10
0
    public function widget($args, $instance)
    {
        if (userpro_get_option('userpro_invite_emails_enable') == 1 && is_user_logged_in()) {
            $text = empty($instance['text']) ? '' : apply_filters('widget_text', $instance['text']);
            echo $args['before_widget'];
            if (!empty($instance['title'])) {
                echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
            }
            ?>
	
	<?php 
            include userpro_path . "templates/inviter_user_widgets.php";
            echo $args['after_widget'];
        }
    }
Exemple #11
0
function userpro_update_1024()
{
    if (!userpro_update_installed('1024') && get_option('userpro_pages')) {
        $pages = get_option('userpro_pages');
        if (!isset($pages['logout_page'])) {
            $slug_logout = userpro_get_option('slug_logout');
            $logout_page = array('post_title' => __('Logout', 'userpro'), 'post_content' => '', 'post_name' => $slug_logout, 'comment_status' => 'closed', 'post_type' => 'page', 'post_status' => 'publish', 'post_author' => 1);
            $logout_page = wp_insert_post($logout_page);
            $pages['logout_page'] = $logout_page;
            $post = get_post($logout_page, ARRAY_A);
            userpro_set_option('slug_logout', $post['post_name']);
            update_option('userpro_pages', $pages);
            update_option("userpro_update_1024", 1);
        }
    }
}
Exemple #12
0
 function new_notification($to, $user_id = 0, $action)
 {
     global $userpro;
     $headers = 'From: ' . userpro_get_option('mail_from_name') . ' <' . userpro_get_option('mail_from') . '>' . "\r\n";
     switch ($action) {
         case 'new_follow':
             $subject = sprintf(__('%s is now following you!', 'userpro'), userpro_profile_data('display_name', $user_id));
             $message = __('Hi there,', 'userpro') . "\r\n\r\n";
             $message .= sprintf(__("%s is now following you on %s! You can click the following link to view his/her profile:", "userpro"), userpro_profile_data('display_name', $user_id), userpro_get_option('mail_from_name')) . "\r\n";
             $message .= $userpro->permalink($user_id) . "\r\n\r\n";
             $message .= __("Or view your profile at:", "userpro") . "\r\n";
             $message .= $userpro->permalink($to->ID) . "\r\n\r\n";
             $message .= __('This is an automated notification that was sent to you by UserPro. No further action is needed.', 'userpro');
             break;
     }
     wp_mail($to->user_email, $subject, $message, $headers);
 }
function userpro_sc_bar($args)
{
    global $userpro, $userpro_social;
    extract($args);
    if (!userpro_get_option('modstate_social')) {
        return false;
    }
    // where to add the hook
    if (in_array($args['template'], array('view', 'following', 'followers')) && !isset($args['no_style'])) {
        ?>
		
		<div class="userpro-sc-bar">
		
			<div class="userpro-sc-left">
				<a href="<?php 
        echo $userpro->permalink($user_id, 'following', 'userpro_sc_pages');
        ?>
" class="userpro-count-link"><?php 
        echo $userpro_social->following_count($user_id);
        ?>
</a>
				<a href="<?php 
        echo $userpro->permalink($user_id, 'followers', 'userpro_sc_pages');
        ?>
" class="userpro-count-link"><?php 
        echo $userpro_social->followers_count($user_id);
        ?>
</a>
			</div>
			
			<div class="userpro-sc-right">
				<?php 
        echo $userpro_social->follow_text($user_id, get_current_user_id());
        ?>
				<?php 
        do_action('userpro_social_buttons', $user_id);
        ?>
			</div>
			
			<div class="userpro-clear"></div>
		
		</div>
		
		<?php 
    }
}
Exemple #14
0
 function email_broadcaster($to, $msg)
 {
     global $userpro;
     if (userpro_msg_get_option('email_notifications') == 1) {
         $user = get_userdata($to);
         $display_name = userpro_profile_data('display_name', userpro_get_option('mail_from'));
         $subject = sprintf(__('Your Message has been Broadcast Successful!', 'userpro-msg'), $display_name);
         // message
         $msg = stripslashes($msg);
         $body = __('Hi there,', 'userpro-msg') . "<br>";
         $body .= sprintf(__('Your message has been broadcasted successfully', 'userpro-msg'), userpro_get_option('mail_from_name'), $display_name) . "<br>";
         $body .= sprintf(__('The message you have broadcasted is :', 'userpro-msg')) . "<br>";
         $body .= "===========================================" . "<br>";
         $body .= $msg . "<br>";
         $body .= "===========================================" . "<br>";
         $headers = 'From: ' . userpro_get_option('mail_from_name') . ' <' . userpro_get_option('mail_from') . '>' . "\r\n";
         $headers .= "MIME-Version: 1.0" . "\r\n";
         $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
         wp_mail($user->user_email, $subject, $body, $headers);
     }
 }
Exemple #15
0
function userpro_init()
{
    if (!isset($_SESSION)) {
        session_start();
    }
    global $userpro;
    $result = get_option("userpro_invite_check");
    if (empty($result)) {
        $user_invite_template = userpro_get_option('userpro_invite_emails_template');
        $userpro_options = get_option('userpro');
        $userpro_options['userpro_invite_emails_template'] = str_replace("inivitelink", "invitelink", userpro_get_option('userpro_invite_emails_template'));
        update_option('userpro', $userpro_options);
        update_option("userpro_invite_check", "1");
    }
    $userpro->do_uploads_dir();
    load_plugin_textdomain('userpro', false, dirname(plugin_basename(__FILE__)) . '/languages');
    /* include libs */
    require_once userpro_path . '/lib/envato/Envato_marketplaces.php';
    if (!class_exists('UserProMailChimp')) {
        require_once userpro_path . '/lib/mailchimp/MailChimp.php';
    }
}
Exemple #16
0
    if (userpro_get_option('facebook_publish_autopost_description')) {
        $description = userpro_get_option('facebook_publish_autopost_description');
        // full description
    } else {
        $description = '';
    }
    if (userpro_get_option('facebook_publish_autopost_link')) {
        $link = userpro_get_option('facebook_publish_autopost_link');
        // link
    } else {
        $link = '';
    }
    ?>

<div id="fb-post-data" data-fbappid="<?php 
    echo userpro_get_option('facebook_app_id');
    ?>
" data-message="<?php 
    echo $body;
    ?>
" data-caption="<?php 
    echo $caption;
    ?>
" data-link="<?php 
    echo $link;
    ?>
" data-name="<?php 
    echo $name;
    ?>
" data-description="<?php 
    echo $description;
/**
	Sends mail
	This function manage the Mail stuff sent by plugin
	to users
	**/
function userpro_mail($id, $template = null, $var1 = null, $form = null)
{
    global $userpro;
    $user = get_userdata($id);
    $builtin = array('{USERPRO_ADMIN_EMAIL}' => userpro_get_option('mail_from'), '{USERPRO_BLOGNAME}' => userpro_get_option('mail_from_name'), '{USERPRO_BLOG_URL}' => home_url(), '{USERPRO_BLOG_ADMIN}' => admin_url(), '{USERPRO_LOGIN_URL}' => $userpro->permalink(0, 'login'), '{USERPRO_USERNAME}' => $user->user_login, '{USERPRO_FIRST_NAME}' => userpro_profile_data('first_name', $user->ID), '{USERPRO_LAST_NAME}' => userpro_profile_data('last_name', $user->ID), '{USERPRO_NAME}' => userpro_profile_data('display_name', $user->ID), '{USERPRO_EMAIL}' => $user->user_email, '{USERPRO_PROFILE_LINK}' => $userpro->permalink($user->ID), '{USERPRO_VALIDATE_URL}' => $userpro->create_validate_url($user->ID), '{USERPRO_PENDING_REQUESTS_URL}' => admin_url() . '?page=userpro&tab=requests', '{USERPRO_ACCEPT_VERIFY_INVITE}' => $userpro->accept_invite_to_verify($user->ID));
    if (isset($var1) && !empty($var1)) {
        $builtin['{VAR1}'] = $var1;
    }
    if (isset($form) && $form != '') {
        $builtin['{USERPRO_PROFILE_FIELDS}'] = $userpro->extract_profile_for_mail($user->ID, $form);
    }
    $search = array_keys($builtin);
    $replace = array_values($builtin);
    $headers = 'From: ' . userpro_get_option('mail_from_name') . ' <' . userpro_get_option('mail_from') . '>' . "\r\n";
    /////////////////////////////////////////////////////////
    /* verify email/new registration */
    /////////////////////////////////////////////////////////
    if ($template == 'verifyemail') {
        $subject = userpro_get_option('mail_verifyemail_s');
        $message = userpro_get_option('mail_verifyemail');
        $message = str_replace($search, $replace, $message);
    }
    /////////////////////////////////////////////////////////
    /* secret key request */
    /////////////////////////////////////////////////////////
    if ($template == 'secretkey') {
        $subject = userpro_get_option('mail_secretkey_s');
        $message = userpro_get_option('mail_secretkey');
        $message = str_replace($search, $replace, $message);
    }
    /////////////////////////////////////////////////////////
    /* account being removed */
    /////////////////////////////////////////////////////////
    if ($template == 'accountdeleted') {
        $subject = userpro_get_option('mail_accountdeleted_s');
        $message = userpro_get_option('mail_accountdeleted');
        $message = str_replace($search, $replace, $message);
    }
    /////////////////////////////////////////////////////////
    /* verification invite */
    /////////////////////////////////////////////////////////
    if ($template == 'verifyinvite') {
        $subject = userpro_get_option('mail_verifyinvite_s');
        $message = userpro_get_option('mail_verifyinvite');
        $message = str_replace($search, $replace, $message);
    }
    /////////////////////////////////////////////////////////
    /* account being verified */
    /////////////////////////////////////////////////////////
    if ($template == 'accountverified') {
        $subject = userpro_get_option('mail_accountverified_s');
        $message = userpro_get_option('mail_accountverified');
        $message = str_replace($search, $replace, $message);
    }
    /////////////////////////////////////////////////////////
    /* account being unverified */
    /////////////////////////////////////////////////////////
    if ($template == 'accountunverified') {
        $subject = userpro_get_option('mail_accountunverified_s');
        $message = userpro_get_option('mail_accountunverified');
        $message = str_replace($search, $replace, $message);
    }
    /////////////////////////////////////////////////////////
    /* new user's account */
    /////////////////////////////////////////////////////////
    if ($template == 'newaccount' && !$userpro->is_pending($user->ID)) {
        $subject = userpro_get_option('mail_newaccount_s');
        $message = userpro_get_option('mail_newaccount');
        $message = str_replace($search, $replace, $message);
    }
    /////////////////////////////////////////////////////////
    /* email user except: profileupdate */
    /////////////////////////////////////////////////////////
    if ($template != 'profileupdate' && $template != 'pendingapprove') {
        wp_mail($user->user_email, $subject, $message, $headers);
    }
    /////////////////////////////////////////////////////////
    /* admin emails notifications */
    /////////////////////////////////////////////////////////
    if ($template == 'pendingapprove') {
        $subject = userpro_get_option('mail_admin_pendingapprove_s');
        $message = userpro_get_option('mail_admin_pendingapprove');
        $message = str_replace($search, $replace, $message);
        wp_mail(userpro_get_option('mail_from'), $subject, $message, $headers);
    }
    if ($template == 'newaccount') {
        $subject = userpro_get_option('mail_admin_newaccount_s');
        $message = userpro_get_option('mail_admin_newaccount');
        $message = str_replace($search, $replace, $message);
        wp_mail(userpro_get_option('mail_from'), $subject, $message, $headers);
    }
    if ($template == 'accountdeleted' && userpro_get_option('notify_admin_profile_remove')) {
        $subject = userpro_get_option('mail_admin_accountdeleted_s');
        $message = userpro_get_option('mail_admin_accountdeleted');
        $message = str_replace($search, $replace, $message);
        wp_mail(userpro_get_option('mail_from'), $subject, $message, $headers);
    }
    if ($template == 'profileupdate') {
        $subject = userpro_get_option('mail_admin_profileupdate_s');
        $message = userpro_get_option('mail_admin_profileupdate');
        $message = str_replace($search, $replace, $message);
        wp_mail(userpro_get_option('mail_from'), $subject, $message, $headers);
    }
}
function userpro_edit_field($key, $array, $i, $args, $user_id = null)
{
    global $userpro;
    extract($array);
    extract($args);
    $res = null;
    /**
    		include & exclude
    		done by custom shortcode
    		params 
    		start here 
    		**/
    if (isset($args['exclude_fields']) && $args['exclude_fields'] != '') {
        if (in_array($key, explode(',', $args['exclude_fields']))) {
            $res = '';
            return false;
        }
    }
    if (isset($args['exclude_fields_by_name']) && $args['exclude_fields_by_name'] != '') {
        if (in_array($array['label'], explode(',', $args['exclude_fields_by_name']))) {
            $res = '';
            return false;
        }
    }
    if (isset($args['exclude_fields_by_type']) && $args['exclude_fields_by_type'] != '') {
        if (isset($array['type']) && in_array($array['type'], explode(',', $args['exclude_fields_by_type']))) {
            $res = '';
            return false;
        }
    }
    if (isset($args['include_fields']) && $args['include_fields'] != '') {
        if (!in_array($key, explode(',', $args['include_fields']))) {
            $res = '';
            return false;
        }
    }
    if (isset($args['include_fields_by_name']) && $args['include_fields_by_name'] != '') {
        if (!in_array($array['label'], explode(',', $args['include_fields_by_name']))) {
            $res = '';
            return false;
        }
    }
    if (isset($args['include_fields_by_type']) && $args['include_fields_by_type'] != '') {
        if (isset($array['type']) && !in_array($array['type'], explode(',', $args['include_fields_by_type'])) || !isset($array['type'])) {
            $res = '';
            return false;
        }
    }
    /**
    		end here
    		thanks please do not edit 
    		here unless you know what you do
    		**/
    /* get field data */
    $data = null;
    /* default ajax callbacks/checks */
    if ($key == 'user_login' && $args['template'] == 'register') {
        if (!isset($array['ajaxcheck']) || $array['ajaxcheck'] == '') {
            $array['ajaxcheck'] = 'username_exists';
        }
    }
    if ($key == 'user_email' && $args['template'] == 'register') {
        if (!isset($array['ajaxcheck']) || $array['ajaxcheck'] == '') {
            $array['ajaxcheck'] = 'email_exists';
        }
    }
    if ($key == 'display_name' && $args['template'] == 'edit') {
        if (!isset($array['ajaxcheck']) || $array['ajaxcheck'] == '') {
            $array['ajaxcheck'] = 'display_name_exists';
        }
    }
    if ($key == 'display_name' && $args['template'] == 'register') {
        if (!isset($array['ajaxcheck']) || $array['ajaxcheck'] == '') {
            $array['ajaxcheck'] = 'display_name_exists';
        }
    }
    foreach ($array as $data_option => $data_value) {
        if (!is_array($data_value)) {
            $data .= " data-{$data_option}='{$data_value}'";
        }
    }
    /* disable editing */
    if (userpro_user_cannot_edit($array)) {
        $data .= ' disabled="disabled"';
    }
    /* if editing an already user */
    if ($user_id) {
        $is_hidden = userpro_profile_data('hide_' . $key, $user_id);
        $value = userpro_profile_data($key, $user_id);
        if (isset($array['type']) && $array['type'] == 'picture') {
            if ($key == 'profilepicture') {
                $value = get_avatar($user_id, 64);
            } else {
                $crop = userpro_profile_data($key, $user_id);
                if (!$crop) {
                    $value = '<span class="userpro-pic-none">' . __('No file has been uploaded.', 'userpro') . '</span>';
                } else {
                    $value = '';
                }
                if (isset($array['width'])) {
                    $width = $array['width'];
                    $height = $array['height'];
                } else {
                    $width = '';
                    $height = '';
                }
                $value .= '<img src="' . $crop . '" width="' . $width . '" height="' . $height . '" alt="" class="modified" />';
            }
        }
        if (isset($array['type']) && $array['type'] == 'file') {
            $value = '<span class="userpro-pic-none">' . __('No file has been uploaded.', 'userpro') . '</span>';
            $file = userpro_profile_data($key, $user_id);
            if ($file) {
                $value = '<div class="userpro-file-input"><a href="' . $file . '" ' . userpro_file_type_icon($file) . '>' . basename($file) . '</a></div>';
            }
        }
    } else {
        // perhaps in registration
        if (isset($array['type']) && $array['type'] == 'picture') {
            if ($key == 'profilepicture') {
                $array['default'] = get_avatar(0, 64);
            }
        }
        if (isset($array['hidden'])) {
            $is_hidden = $array['hidden'];
        }
        if (isset($array['default'])) {
            $value = $array['default'];
        }
    }
    if (!isset($value)) {
        $value = null;
    }
    if (!isset($array['placeholder'])) {
        $array['placeholder'] = null;
    }
    /* remove passwords */
    if (isset($array['type']) && $array['type'] == 'password') {
        $value = null;
    }
    /* display a section */
    if ($allow_sections && isset($array['heading'])) {
        $res .= "<div class='userpro-section userpro-column userpro-collapsible-" . $array['collapsible'] . " userpro-collapsed-" . $array['collapsed'] . "'>" . $array['heading'] . "</div>";
    }
    /* display a field */
    if (!$user_id) {
        $user_id = 0;
    }
    if (isset($array['type']) && userpro_field_by_role($key, $user_id)) {
        $res .= "<div class='userpro-field userpro-field-" . $key . " " . userpro_private_field_class($array) . "' data-key='{$key}'>";
        if ($array['label'] && $array['type'] != 'passwordstrength') {
            if ($args['field_icons'] == 1) {
                $res .= "<div class='userpro-label iconed'>";
            } else {
                $res .= "<div class='userpro-label'>";
            }
            $res .= "<label for='{$key}-{$i}'>" . $array['label'] . "</label>";
            if (isset($array['required']) && $array['required'] == 1) {
                $res .= "<div class='required'>*</div>";
            }
            if ($args['field_icons'] == 1 && $userpro->field_icon($key)) {
                $res .= '<span class="userpro-field-icon"><i class="userpro-icon-' . $userpro->field_icon($key) . '"></i></span>';
            }
            if ($args['template'] != 'login' && isset($array['help']) && $array['help'] != '') {
                $res .= '<span class="userpro-tip" title="' . stripslashes($array['help']) . '"></span>';
            }
            $res .= "</div>";
        }
        $res .= "<div class='userpro-input'>";
        /* switch field type */
        switch ($array['type']) {
            case 'picture':
                if (!isset($array['button_text']) || $array['button_text'] == '') {
                    $array['button_text'] = __('Upload photo', 'userpro');
                }
                $res .= "<div class='userpro-pic userpro-pic-" . $key . "' data-remove_text='" . __('Remove', 'userpro') . "'>" . $value . "</div>";
                $res .= "<div class='userpro-pic-upload' data-filetype='picture' data-allowed_extensions='png,gif,jpg,jpeg'>" . $array['button_text'] . "</div>";
                if ($user_id && userpro_profile_data($key, $user_id)) {
                    $res .= "<input type='button' value='" . __('Remove', 'userpro') . "' class='userpro-button red' />";
                }
                $res .= "<input data-required='" . $array['required'] . "' type='hidden' name='{$key}-{$i}' id='{$key}-{$i}' value='" . userpro_profile_data($key, $user_id) . "' />";
                break;
            case 'file':
                if (!isset($array['button_text']) || $array['button_text'] == '') {
                    $array['button_text'] = __('Upload file', 'userpro');
                }
                $res .= "<div class='userpro-pic' data-remove_text='" . __('Remove', 'userpro') . "'>" . $value . "</div>";
                $res .= "<div class='userpro-pic-upload' data-filetype='file' data-allowed_extensions='" . $array['allowed_extensions'] . "'>" . $array['button_text'] . "</div>";
                if ($user_id && userpro_profile_data($key, $user_id)) {
                    $res .= "<input type='button' value='" . __('Remove', 'userpro') . "' class='userpro-button red' />";
                }
                $res .= "<input data-required='" . $array['required'] . "' type='hidden' name='{$key}-{$i}' id='{$key}-{$i}' value='" . userpro_profile_data($key, $user_id) . "' />";
                break;
            case 'datepicker':
                $res .= "<input data-fieldtype='datepicker' class='userpro-datepicker' type='text' name='{$key}-{$i}' id='{$key}-{$i}' value='" . $value . "' placeholder='" . $array['placeholder'] . "' {$data} />";
                /* allow user to make it hideable */
                if (isset($array['hideable']) && $array['hideable'] == 1) {
                    $res .= "<label class='userpro-checkbox hide-field'><span";
                    if (checked($hideable, $is_hidden, 0)) {
                        $res .= ' class="checked"';
                    }
                    $res .= "></span><input type='checkbox' value='{$hideable}' name='hide_{$key}-{$i}'";
                    $res .= checked($hideable, $is_hidden, 0);
                    $res .= " />" . __('Make this field hidden from public', 'userpro') . "</label>";
                }
                break;
            case 'text':
                $res .= "<input type='text' name='{$key}-{$i}' id='{$key}-{$i}' value=" . '"' . $value . '"' . " placeholder='" . $array['placeholder'] . "' {$data} />";
                /* allow user to make it hideable */
                if (isset($array['hideable']) && $array['hideable'] == 1) {
                    $res .= "<label class='userpro-checkbox hide-field'><span";
                    if (checked($hideable, $is_hidden, 0)) {
                        $res .= ' class="checked"';
                    }
                    $res .= "></span><input type='checkbox' value='{$hideable}' name='hide_{$key}-{$i}'";
                    $res .= checked($hideable, $is_hidden, 0);
                    $res .= " />" . __('Make this field hidden from public', 'userpro') . "</label>";
                }
                break;
            case 'antispam':
                $rand1 = rand(1, 10);
                $rand2 = rand(1, 10);
                $res .= sprintf(__('Answer: %s + %s', 'userpro'), $rand1, $rand2);
                $res .= "<input type='text' name='{$key}-{$i}' id='{$key}-{$i}' value='' {$data} />";
                $res .= "<input type='hidden' name='answer-{$i}' id='answer-{$i}' value='" . ($rand1 + $rand2) . "' />";
                break;
            case 'textarea':
                if (isset($array['size'])) {
                    $size = $array['size'];
                } else {
                    $size = 'normal';
                }
                $res .= "<textarea class='{$size}' type='text' name='{$key}-{$i}' id='{$key}-{$i}' {$data} >{$value}</textarea>";
                /* allow user to make it hideable */
                if ($array['hideable'] == 1) {
                    $res .= "<label class='userpro-checkbox hide-field'><span";
                    if (checked($hideable, $is_hidden, 0)) {
                        $res .= ' class="checked"';
                    }
                    $res .= "></span><input type='checkbox' value='{$hideable}' name='hide_{$key}-{$i}'";
                    $res .= checked($hideable, $is_hidden, 0);
                    $res .= " />" . __('Make this field hidden from public', 'userpro') . "</label>";
                }
                break;
            case 'password':
                $res .= "<input type='password' name='{$key}-{$i}' id='{$key}-{$i}' value='" . $value . "' placeholder='" . $array['placeholder'] . "' autocomplete='off' {$data} />";
                break;
            case 'passwordstrength':
                $res .= '<span class="strength-text" ' . $data . '>' . __('Password Strength', 'userpro') . '</span><div class="userpro-clear"></div><span class="strength-container"><span class="strength-plain"></span><span class="strength-plain"></span><span class="strength-plain"></span><span class="strength-plain"></span><span class="strength-plain"></span></span><div class="userpro-clear"></div>';
                break;
            case 'select':
                if (isset($options)) {
                    $countrylist = get_option('userpro_fields');
                    if (isset($countrylist['billing_country']['options'])) {
                        $country = $countrylist['billing_country']['options'];
                    }
                    if ($key == 'shipping_country') {
                        foreach ($country as $country_code => $country_name) {
                            if ($country_code == $value || $country_name == $value) {
                                $value = $country_name;
                                if (!isset($value)) {
                                    $value = 0;
                                }
                                if (isset($array['default']) && !$value) {
                                    $value = $array['default'];
                                }
                                $res .= "<select name='{$key}-{$i}' id='{$key}-{$i}' class='chosen-select' data-placeholder='" . $array['placeholder'] . "' {$data} >";
                                if (is_array($options)) {
                                    if (isset($array['placeholder']) && !empty($array['placeholder'])) {
                                        $res .= '<option value="" ' . selected(0, $value, 0) . '></option>';
                                    }
                                    foreach ($options as $k => $v) {
                                        $v = stripslashes($v);
                                        $res .= '<option value="' . $v . '" ' . selected($v, $value, 0) . '>' . $v . '</option>';
                                    }
                                }
                                $res .= "</select>";
                            }
                        }
                    } elseif ($key == 'billing_country') {
                        foreach ($country as $country_code => $country_name) {
                            if ($country_code == $value || $country_name == $value) {
                                $value = $country_name;
                                if (!isset($value)) {
                                    $value = 0;
                                }
                                if (isset($array['default']) && !$value) {
                                    $value = $array['default'];
                                }
                                $res .= "<select name='{$key}-{$i}' id='{$key}-{$i}' class='chosen-select' data-placeholder='" . $array['placeholder'] . "' {$data} >";
                                if (is_array($options)) {
                                    if (isset($array['placeholder']) && !empty($array['placeholder'])) {
                                        $res .= '<option value="" ' . selected(0, $value, 0) . '></option>';
                                    }
                                    foreach ($options as $k => $v) {
                                        $v = stripslashes($v);
                                        $res .= '<option value="' . $v . '" ' . selected($v, $value, 0) . '>' . $v . '</option>';
                                    }
                                }
                                $res .= "</select>";
                            }
                        }
                    } elseif ($key == 'role') {
                        $options = userpro_get_roles(userpro_get_option('allowed_roles'));
                        if (!isset($value)) {
                            $value = 0;
                        }
                        $res .= "<select name='{$key}-{$i}' id='{$key}-{$i}' class='chosen-select' data-placeholder='" . $array['placeholder'] . "' {$data} >";
                        if (is_array($options)) {
                            if (isset($array['placeholder']) && !empty($array['placeholder'])) {
                                $res .= '<option value="" ' . selected(0, $value, 0) . '></option>';
                            }
                            foreach ($options as $k => $v) {
                                $v = stripslashes($v);
                                $res .= '<option value="' . $k . '" ' . selected($k, $value, 0) . '>' . $v . '</option>';
                            }
                        }
                        $res .= "</select>";
                    } else {
                        if (!isset($value)) {
                            $value = 0;
                        }
                        if (isset($array['default']) && !$value) {
                            $value = $array['default'];
                        }
                        $res .= "<select name='{$key}-{$i}' id='{$key}-{$i}' class='chosen-select' data-placeholder='" . $array['placeholder'] . "' {$data} >";
                        if (is_array($options)) {
                            if (isset($array['placeholder']) && !empty($array['placeholder'])) {
                                $res .= '<option value="" ' . selected(0, $value, 0) . '></option>';
                            }
                            foreach ($options as $k => $v) {
                                $v = stripslashes($v);
                                $res .= '<option value="' . $v . '" ' . selected($v, $value, 0) . '>' . $v . '</option>';
                            }
                        }
                        $res .= "</select>";
                    }
                    /* allow user to make it hideable */
                    if ($array['hideable'] == 1) {
                        $res .= "<label class='userpro-checkbox hide-field'><span";
                        if (checked($hideable, $is_hidden, 0)) {
                            $res .= ' class="checked"';
                        }
                        $res .= "></span><input type='checkbox' value='{$hideable}' name='hide_{$key}-{$i}'";
                        $res .= checked($hideable, $is_hidden, 0);
                        $res .= " />" . __('Make this field hidden from public', 'userpro') . "</label>";
                    }
                }
                break;
            case 'multiselect':
                if (isset($options)) {
                    $res .= "<select name='" . $key . '-' . $i . '[]' . "' multiple='multiple' class='chosen-select' data-placeholder='" . $array['placeholder'] . "'>";
                    foreach ($options as $k => $v) {
                        $v = stripslashes($v);
                        if (strstr($k, 'optgroup_b')) {
                            $res .= "<optgroup label='{$v}'>";
                        } elseif (strstr($k, 'optgroup_e')) {
                            $res .= "</optgroup>";
                        } else {
                            $res .= '<option value="' . $v . '" ';
                            if (is_array($value) && in_array($v, $value) || $v == $value) {
                                $res .= 'selected="selected"';
                            }
                            $res .= '>' . $v . '</option>';
                        }
                    }
                    $res .= "</select>";
                }
                break;
            case 'checkbox':
                if (isset($options)) {
                    $res .= "<div class='userpro-checkbox-wrap' data-required='" . $array['required'] . "'>";
                    foreach ($options as $k => $v) {
                        $v = stripslashes($v);
                        $res .= "<label class='userpro-checkbox'><span";
                        if (is_array($value) && in_array($v, $value) || $v == $value) {
                            $res .= ' class="checked"';
                        }
                        $res .= '></span><input type="checkbox" value="' . $v . '" name="' . $key . '-' . $i . '[]" ';
                        if (is_array($value) && in_array($v, $value) || $v == $value) {
                            $res .= 'checked="checked"';
                        }
                        $res .= " />{$v}</label>";
                    }
                    $res .= "</div>";
                }
                break;
            case 'checkbox-full':
                if (isset($options)) {
                    $res .= "<div class='userpro-checkbox-wrap' data-required='" . $array['required'] . "'>";
                    foreach ($options as $k => $v) {
                        $v = stripslashes($v);
                        $res .= "<label class='userpro-checkbox full'><span";
                        if (is_array($value) && in_array($v, $value) || $v == $value) {
                            $res .= ' class="checked"';
                        }
                        $res .= '></span><input type="checkbox" value="' . $v . '" name="' . $key . '-' . $i . '[]" ';
                        if (is_array($value) && in_array($v, $value) || $v == $value) {
                            $res .= 'checked="checked"';
                        }
                        $res .= " />{$v}</label>";
                    }
                    $res .= "</div>";
                }
                break;
            case 'mailchimp':
                if (!isset($array['list_text'])) {
                    $array['list_text'] = __('Subscribe to our newsletter', 'userpro');
                }
                if ($userpro->mailchimp_is_subscriber($user_id, $array['list_id'])) {
                    $res .= "<div class='userpro-checkbox-wrap'>";
                    $res .= "<div class='userpro-help'><i class='userpro-icon-ok'></i>" . __('You are currently subscribed to this newsletter.', 'userpro') . "</div>";
                    $res .= "<label class='userpro-checkbox full'><span";
                    $res .= '></span><input type="checkbox" value="subscribed" name="' . $key . '-' . $i . '" ';
                    $res .= " />" . __('Unsubscribe from this newsletter', 'userpro') . "</label>";
                    $res .= "</div>";
                } else {
                    $res .= "<div class='userpro-checkbox-wrap'>";
                    $res .= "<label class='userpro-checkbox full'><span";
                    $res .= '></span><input type="checkbox" value="unsubscribed" name="' . $key . '-' . $i . '" ';
                    $res .= " />" . $array['list_text'] . "</label>";
                    $res .= "</div>";
                }
                break;
            case 'followers':
                if ($userpro->followere_email_subscriber($user_id)) {
                    $res .= "<div class='userpro-checkbox-wrap'>";
                    $res .= "<div class='userpro-help'><i class='userpro-icon-ok'></i>" . __('You are currently receiving following email alerts.', 'userpro') . "</div>";
                    $res .= "<label class='userpro-checkbox full'><span";
                    $res .= '></span><input type="checkbox" value="subscribed" name="' . $key . '-' . $i . '" ';
                    $res .= " />" . __('Remove the following email alert ', 'userpro') . "</label>";
                    $res .= "</div>";
                } else {
                    $res .= "<div class='userpro-checkbox-wrap'>";
                    $res .= "<label class='userpro-checkbox full'><span";
                    $res .= '></span><input type="checkbox" value="unsubscribed" name="' . $key . '-' . $i . '" ';
                    $res .= " />" . $array['follower_text'] . "</label>";
                    $res .= "</div>";
                }
                break;
            case 'radio':
                if (isset($options)) {
                    $res .= "<div class='userpro-radio-wrap' data-required='" . $array['required'] . "'>";
                    foreach ($options as $k => $v) {
                        $v = stripslashes($v);
                        $res .= "<label class='userpro-radio'><span";
                        if (checked($v, $value, 0)) {
                            $res .= ' class="checked"';
                        }
                        $res .= '></span><input type="radio" value="' . $v . '" name="' . $key . '-' . $i . '" ';
                        $res .= checked($v, $value, 0);
                        $res .= " />{$v}</label>";
                    }
                    $res .= "</div>";
                }
                break;
            case 'radio-full':
                if (isset($options)) {
                    $res .= "<div class='userpro-radio-wrap' data-required='" . $array['required'] . "'>";
                    foreach ($options as $k => $v) {
                        $v = stripslashes($v);
                        $res .= "<label class='userpro-radio full'><span";
                        if (checked($v, $value, 0)) {
                            $res .= ' class="checked"';
                        }
                        $res .= '></span><input type="radio" value="' . $v . '" name="' . $key . '-' . $i . '" ';
                        $res .= checked($v, $value, 0);
                        $res .= " />{$v}</label>";
                    }
                    $res .= "</div>";
                }
                break;
                /**
                 * Security Question Answer Starts
                 */
            /**
             * Security Question Answer Starts
             */
            case 'securityqa':
                if (isset($array['security_qa']) && !empty($array['security_qa'])) {
                    $questions = explode("\n", $array['security_qa']);
                    $questionKey = array_rand($questions, 1);
                    $questionAnswer = explode(':', $questions[$questionKey]);
                    $question = $questionAnswer[0];
                    $res .= "<label class=''><span>";
                    $res .= $question . "</span>";
                    $res .= '<input type="hidden" name="securitykey" value="' . $questionKey . '" />';
                }
                $res .= '<input type="text" name="securityqa" value="" />';
                break;
                /**
                 * Security Question Answer End
                 */
        }
        /* end switch field type */
        /* add action for each field */
        $hook = apply_filters("userpro_field_filter", $key, $user_id);
        $res .= $hook;
        $res .= "<div class='userpro-clear'></div>";
        $res .= "</div>";
        $res .= "</div><div class='userpro-clear'></div>";
    }
    return $res;
}
Exemple #19
0
_e('Subject', 'userpro');
?>
</label></th>
		<td><input type="text" name="mail_verifyinvite_s" id="mail_verifyinvite_s" value="<?php 
echo userpro_get_option('mail_verifyinvite_s');
?>
" class="regular-text" /></td>
	</tr>
	
	<tr valign="top">
		<th scope="row"><label for="mail_verifyinvite"><?php 
_e('Email Content', 'userpro');
?>
</label></th>
		<td><textarea name="mail_verifyinvite" id="mail_verifyinvite" class="large-text code" rows="10"><?php 
echo userpro_get_option('mail_verifyinvite');
?>
</textarea></td>
	</tr>
	
</table>

<p class="submit">
	<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php 
_e('Save Changes', 'userpro');
?>
"  />
	<input type="submit" name="reset-options" id="reset-options" class="button" value="<?php 
_e('Reset Options', 'userpro');
?>
"  />
Exemple #20
0
		<td>
			<input type="text" name="envato_api" id="envato_api" value="<?php 
echo userpro_get_option('envato_api');
?>
" class="regular-text" />
		</td>
	</tr>
	
	<tr valign="top">
		<th scope="row"><label for="envato_username"><?php 
_e('Envato Username', 'userpro');
?>
</label></th>
		<td>
			<input type="text" name="envato_username" id="envato_username" value="<?php 
echo userpro_get_option('envato_username');
?>
" class="regular-text" />
		</td>
	</tr>

</table>

<!--Globla hook for adding extra setting fields   Added by Rahul-->
<?php 
do_action("userpro_add_setting_fields");
?>
<p class="submit">
	<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php 
_e('Save Changes', 'userpro');
?>
Exemple #21
0
function userpro_process_form()
{
    global $userpro;
    if (!isset($_POST['_myuserpro_nonce']) || !wp_verify_nonce($_POST['_myuserpro_nonce'], '_myuserpro_nonce_' . $_POST['template'] . '_' . $_POST['unique_id'])) {
        die;
    }
    if (!isset($_POST) || $_POST['action'] != 'userpro_process_form') {
        die;
    }
    if (!userpro_is_logged_in() && $_POST['template'] == 'edit') {
        die;
    }
    extract($_POST);
    foreach ($_POST as $key => $val) {
        $key = explode('-', $key);
        $key = $key[0];
        $form[$key] = $val;
    }
    extract($form);
    /* form action */
    switch ($template) {
        /* publish */
        case 'publish':
            $output['error'] = '';
            if (!$post_title) {
                $output['error']['post_title'] = __('You must enter a post title.', 'userpro');
            }
            if (!$userpro_editor) {
                $output['error']['userpro_editor'] = __('You must enter some content.', 'userpro');
            }
            /*
            	publish post
            */
            if (empty($output['error'])) {
                $array = array('post_title' => $post_title, 'post_content' => @wp_kses($userpro_editor), 'post_author' => $user_id);
                if ($post_type) {
                    $array['post_type'] = $post_type;
                }
                if (userpro_is_admin($user_id)) {
                    $array['post_status'] = 'publish';
                    $post_id = wp_insert_post($array);
                    $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . sprintf(__('Your post has been published. You can view it %s.', 'userpro'), '<a href="' . get_permalink($post_id) . '">here</a>') . '</p></div>';
                } else {
                    // under review
                    $array['post_status'] = 'pending';
                    $post_id = wp_insert_post($array);
                    $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . __('Your post has been sent for review. It will be checked by our staff.', 'userpro') . '</p></div>';
                }
                /*
                	empty category first
                */
                wp_set_object_terms($post_id, NULL, 'category');
                /*
                	taxonomy
                	and category
                */
                if (isset($taxonomy) && isset($category)) {
                    $categories = explode(',', $category);
                    if (is_array($categories)) {
                        foreach ($categories as $cat) {
                            if (is_numeric($cat)) {
                                $cat = (int) $cat;
                            }
                            $cats[] = $cat;
                        }
                        wp_set_object_terms($post_id, $cats, $taxonomy);
                    } else {
                        if (is_numeric($categories)) {
                            $categories = (int) $categories;
                        }
                        wp_set_object_terms($post_id, $categories, $taxonomy);
                    }
                }
                /*
                	multiple taxonomy
                	category insertion
                */
                if (isset($post_categories)) {
                    $i = 0;
                    foreach ($post_categories as $cat) {
                        $i++;
                        $split = explode('#', $cat);
                        $tax = $split[1];
                        $id = $split[0];
                        $terms[$tax][] = $id;
                    }
                    if (is_array($terms)) {
                        foreach ($terms as $k => $arr) {
                            wp_set_object_terms($post_id, $terms[$k], $k, true);
                        }
                    }
                }
                /*
                	assign featured
                	image for post
                */
                if ($post_featured_image) {
                    $attach_id = $userpro->new_attachment($post_id, $post_featured_image);
                    $userpro->set_thumbnail($post_id, $attach_id);
                }
            }
            break;
            /* delete profile */
        /* delete profile */
        case 'delete':
            $output['error'] = '';
            $user = get_userdata($user_id);
            $user_roles = $user->roles;
            $user_role = array_shift($user_roles);
            if (!$confirmdelete) {
                $output['error']['confirmdelete'] = __('Nothing was deleted. You must choose yes to confirm deletion.', 'userpro');
            } elseif ($user_role == 'administrator') {
                $output['error']['confirmdelete'] = __('For security reasons, admin accounts cannot be deleted.', 'userpro');
            } elseif ($user->user_login == 'test') {
                $output['error']['confirmdelete'] = __('You cannot remove test accounts from frontend!', 'userpro');
            } else {
                require_once ABSPATH . 'wp-admin/includes/user.php';
                userpro_mail($user_id, 'accountdeleted');
                // Delete user
                if (is_multisite()) {
                    // Multisite: Deletes user's Posts and Links, then deletes from WP Users|Usermeta
                    // ONLY IF "Delete From Network" setting checked and user only belongs to this blog
                    wpmu_delete_user($user_id);
                } else {
                    // Deletes user's Posts and Links
                    // Multisite: Removes user from current blog
                    // Not Multisite: Deletes user from WP Users|Usermeta
                    wp_delete_user($user_id);
                }
                $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . __('This account has been deleted successfully.', 'userpro') . '</p></div>';
                $output['redirect_uri'] = home_url();
            }
            break;
            /* change pass */
        /* change pass */
        case 'change':
            $output['error'] = '';
            if (!$secretkey) {
                $output['error']['secretkey'] = __('You did not provide a secret key.', 'userpro');
            } elseif (strlen($secretkey) != 20) {
                $output['error']['secretkey'] = __('The secret key you entered is invalid.', 'userpro');
            }
            /* Form validation */
            /* Here you can process custom "errors" before proceeding */
            $output['error'] = apply_filters('userpro_form_validation', $output['error'], $form);
            if (empty($output['error'])) {
                $users = get_users(array('meta_key' => 'userpro_secret_key', 'meta_value' => $secretkey, 'meta_compare' => '='));
                if (!$users[0]) {
                    $output['error']['secretkey'] = __('The secret key is invalid or expired.', 'userpro');
                } else {
                    $user_id = $users[0]->ID;
                    wp_update_user(array('ID' => $user_id, 'user_pass' => $user_pass));
                    delete_user_meta($user_id, 'userpro_secret_key');
                    add_action('userpro_pre_form_message', 'userpro_msg_login_after_passchange');
                    $shortcode = stripslashes($shortcode);
                    $modded = str_replace('template="change"', 'template="login"', $shortcode);
                    $output['template'] = do_shortcode($modded);
                }
            }
            break;
            /* send secret key */
        /* send secret key */
        case 'reset':
            $output['error'] = '';
            if (!$username_or_email) {
                $output['error']['username_or_email'] = __('You should provide your email or username.', 'userpro');
            } else {
                if (is_email($username_or_email)) {
                    $user = get_user_by_email($username_or_email);
                    $username_or_email = $user->user_login;
                }
                if (!username_exists($username_or_email)) {
                    $output['error']['username_or_email'] = __('There is not such user in our system.', 'userpro');
                } elseif (!$userpro->can_reset_pass($username_or_email)) {
                    $output['error']['username_or_email'] = __('Resetting admin password is not permitted!', 'userpro');
                }
            }
            /* Form validation */
            /* Here you can process custom "errors" before proceeding */
            $output['error'] = apply_filters('userpro_form_validation', $output['error'], $form);
            /* email user with secret key and update
            			his user meta */
            if (empty($output['error'])) {
                $user = get_user_by('login', $username_or_email);
                $uniquekey = wp_generate_password(20, $include_standard_special_chars = false);
                update_user_meta($user->ID, 'userpro_secret_key', $uniquekey);
                userpro_mail($user->ID, 'secretkey', $uniquekey);
                add_action('userpro_pre_form_message', 'userpro_msg_secret_key_sent');
                $shortcode = stripslashes($shortcode);
                $modded = str_replace('template="reset"', 'template="change"', $shortcode);
                $output['template'] = do_shortcode($modded);
            }
            break;
            /* login */
        /* login */
        case 'login':
            $output['error'] = '';
            if (!$username_or_email) {
                $output['error']['username_or_email'] = __('You should provide your email or username.', 'userpro');
            }
            if (!$user_pass) {
                $output['error']['user_pass'] = __('You should provide your password.', 'userpro');
            }
            if (email_exists($username_or_email)) {
                $user = get_user_by('email', $username_or_email);
                $username_or_email = $user->user_login;
            }
            /* Form validation */
            /* Here you can process custom "errors" before proceeding */
            $output['error'] = apply_filters('userpro_login_validation', $output['error'], $form);
            if (empty($output['error']) && $username_or_email && $user_pass) {
                $creds = array();
                $creds['user_login'] = $username_or_email;
                $creds['user_password'] = $user_pass;
                $creds['remember'] = true;
                $user = wp_signon($creds, false);
                if (is_wp_error($user)) {
                    if ($user->get_error_code() == 'invalid_username') {
                        $output['error']['username_or_email'] = __('Invalid email or username entered', 'userpro');
                    } elseif ($user->get_error_code() == 'incorrect_password') {
                        $output['error']['user_pass'] = __('The password you entered is incorrect', 'userpro');
                    }
                } else {
                    /* check the account is active first */
                    if ($userpro->is_pending($user->ID)) {
                        if (userpro_get_option('users_approve') === '2') {
                            $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . __('Your email is pending verification. Please activate your account.', 'userpro') . '</p></div>';
                        } else {
                            $output['custom_message'] = '<div class="userpro-message userpro-message-ajax"><p>' . __('Your account is currently being reviewed. Thanks for your patience.', 'userpro') . '</p></div>';
                        }
                        wp_logout();
                    } else {
                        /* a good login */
                        userpro_auto_login($user->user_login, true);
                        if (isset($force_redirect_uri) && !empty($force_redirect_uri)) {
                            $output['redirect_uri'] = 'refresh';
                        } else {
                            if (current_user_can('manage_options') && userpro_get_option('show_admin_after_login')) {
                                $output['redirect_uri'] = admin_url();
                            } else {
                                if (isset($redirect_uri) && !empty($redirect_uri)) {
                                    $output['redirect_uri'] = $redirect_uri;
                                } else {
                                    if (userpro_get_option('after_login') == 'no_redirect') {
                                        $output['redirect_uri'] = 'refresh';
                                    }
                                    if (userpro_get_option('after_login') == 'profile') {
                                        $output['redirect_uri'] = $userpro->permalink();
                                    }
                                }
                            }
                            /* hook the redirect URI */
                            $output['redirect_uri'] = apply_filters('userpro_login_redirect', $output['redirect_uri']);
                        }
                        /* super redirection */
                        if (isset($global_redirect)) {
                            $output['redirect_uri'] = $global_redirect;
                        }
                    }
                    // active/pending
                }
            }
            break;
            /* editing */
        /* editing */
        case 'edit':
            if ($user_id != get_current_user_id() && !current_user_can('manage_options')) {
                die;
            }
            userpro_update_user_profile($user_id, $form, $action = 'ajax_save');
            if (userpro_get_option('notify_admin_profile_save') && !current_user_can('manage_options')) {
                userpro_mail($user_id, 'profileupdate', null, $form);
            }
            add_action('userpro_pre_form_message', 'userpro_msg_profile_saved');
            if ($_POST['up_username']) {
                set_query_var('up_username', $_POST['up_username']);
            }
            $shortcode = stripslashes($shortcode);
            $modded = $shortcode;
            $output['template'] = do_shortcode($modded);
            break;
            /* registering */
        /* registering */
        case 'register':
            $output['error'] = '';
            /* Form validation */
            /* Here you can process custom "errors" before proceeding */
            $output['error'] = apply_filters('userpro_register_validation', $output['error'], $form);
            if (empty($output['error']) && (isset($user_login) && isset($user_email) && isset($user_pass) || isset($user_login) && isset($user_email) || isset($user_email))) {
                if (isset($user_login)) {
                    $user_exists = username_exists($user_login);
                } else {
                    $user_exists = username_exists('the_cow_that_did_run_after_the_elephant');
                    $user_login = $user_email;
                }
                if (!isset($user_exists) and email_exists($user_email) == false) {
                    if (!isset($user_pass)) {
                        $user_pass = wp_generate_password($length = 12, $include_standard_special_chars = false);
                    }
                    /* not auto approved? */
                    if (userpro_get_option('users_approve') !== '1') {
                        /* require email validation */
                        if (userpro_get_option('users_approve') === '2') {
                            $user_id = $userpro->new_user($user_login, $user_pass, $user_email, $form, $type = 'standard', $approved = 0);
                            $userpro->pending_email_approve($user_id, $user_pass, $form);
                            add_action('userpro_pre_form_message', 'userpro_msg_activate_pending');
                            $shortcode = stripslashes($shortcode);
                            $modded = str_replace('template="register"', 'template="login"', $shortcode);
                            $output['template'] = do_shortcode($modded);
                        }
                        /* require admin validation */
                        if (userpro_get_option('users_approve') === '3') {
                            $user_id = $userpro->new_user($user_login, $user_pass, $user_email, $form, $type = 'standard', $approved = 0);
                            $userpro->pending_admin_approve($user_id, $user_pass, $form);
                            add_action('userpro_pre_form_message', 'userpro_msg_activate_pending_admin');
                            $shortcode = stripslashes($shortcode);
                            $modded = str_replace('template="register"', 'template="login"', $shortcode);
                            $output['template'] = do_shortcode($modded);
                        }
                    } else {
                        $user_id = $userpro->new_user($user_login, $user_pass, $user_email, $form, $type = 'standard');
                        /* auto login */
                        if (userpro_get_option('after_register_autologin')) {
                            $creds = array();
                            $creds['user_login'] = $user_login;
                            $creds['user_password'] = $user_pass;
                            $creds['remember'] = true;
                            $user = wp_signon($creds, false);
                            if (isset($user->user_login)) {
                                userpro_auto_login($user->user_login, true);
                            }
                            if ($redirect_uri) {
                                $output['redirect_uri'] = $redirect_uri;
                            } else {
                                if (userpro_get_option('after_register') == 'no_redirect') {
                                    $output['redirect_uri'] = 'refresh';
                                }
                                if (userpro_get_option('after_register') == 'profile') {
                                    $output['redirect_uri'] = $userpro->permalink();
                                }
                            }
                            /* hook the redirect URI */
                            $output['redirect_uri'] = apply_filters('userpro_register_redirect', $output['redirect_uri']);
                            /* manual login form */
                        } else {
                            add_action('userpro_pre_form_message', 'userpro_msg_login_after_reg');
                            $shortcode = stripslashes($shortcode);
                            $modded = str_replace('template="register"', 'template="login"', $shortcode);
                            $output['template'] = do_shortcode($modded);
                        }
                    }
                }
            }
            break;
    }
    $output = json_encode($output);
    if (is_array($output)) {
        print_r($output);
    } else {
        echo $output;
    }
    die;
}
function userpro_social_connect_add($args = array())
{
    global $userpro;
    ob_start();
    $defaults = array('width' => 'auto', 'size' => 'normal', 'facebook' => 1, 'facebook_title' => __('Login with Facebook', 'userpro'), 'facebook_redirect' => 'profile', 'twitter' => 1, 'twitter_title' => __('Login with Twitter', 'userpro'), 'google' => 1, 'google_title' => __('Login with Google+', 'userpro'), 'vk' => 1, 'vk_title' => __('ВКонтакте', 'userpro'));
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    echo '<div class="userpro-social-big">';
    if ($facebook == 1 && userpro_get_option('facebook_app_id') != '' && userpro_get_option('facebook_connect') == 1) {
        ?>
				
				<div id="fb-root" class="userpro-column"></div>
				<script>
				window.fbAsyncInit = function() {
					
					FB.init({
						appId      : "<?php 
        echo userpro_get_option('facebook_app_id');
        ?>
", // Set YOUR APP ID
						status     : true, // check login status
						cookie     : true, // enable cookies to allow the server to access the session
						xfbml      : true,  // parse XFBML
						version    : "v2.0"
					});
			 
					FB.Event.subscribe('auth.authResponseChange', function(response)
					{
					if (response.status === 'connected')
					{
					//SUCCESS
			 
					}   
					else if (response.status === 'not_authorized')
					{
					//FAILED
					
					} else
					{
					//UNKNOWN ERROR
					
					}
					});
			 
				};
			 
				// Login user
				function Login(element){
					
					var form = jQuery(element).parents('.userpro').find('form');
					userpro_init_load( form );
					
					if ( element.data('redirect')) {
						var redirect = element.data('redirect');
					} else {
						var redirect = '';
					}

					FB.login(function(response) {
						if (response.authResponse){
							// post to wall
							<?php 
        $scope = 'email,user_photos';
        ?>
 // end post to wall ?>
							
							// get profile picture
							FB.api('/me/picture?type=large', function(response) {
								profilepicture = response.data.url;
							});
							
							// connect via facebook
							FB.api('/me', function(response) {
								
								jQuery.ajax({
									url: userpro_ajax_url,
									data: "action=userpro_fbconnect&id="+response.id+"&username="******"&first_name="+response.first_name+"&last_name="+response.last_name+"&gender="+response.gender+"&email="+response.email+"&name="+response.name+"&link="+response.link+"&profilepicture="+profilepicture+"&redirect="+redirect,
									dataType: 'JSON',
									type: 'POST',
									success:function(data){
									
										userpro_end_load( form );
										
										/* custom message */
										if (data.custom_message){
										form.parents('.userpro').find('.userpro-body').prepend( data.custom_message );
										}
										
										/* redirect after form */
										if (data.redirect_uri){
											if (data.redirect_uri =='refresh') {
												document.location.href=jQuery(location).attr('href');
											} else {
												document.location.href=data.redirect_uri;
											}
										}
										
									},
									error: function(){
										alert('Something wrong happened.');
									}
								});
							
							});
							
						// cancelled
						} else {
							alert( 'Unauthorized or cancelled' );
							userpro_end_load( form );
						}
					},{scope: '<?php 
        echo $scope;
        ?>
' , return_scopes: true});
			 
				}
				
				// Logout
				function Logout(){
					FB.logout(function(){document.location.reload();});
				}
			 
				// Load the SDK asynchronously
				// Load the SDK asynchronously
				(function(d,s,id){
					var js, fjs = d.getElementsByTagName(s)[0];
					if (d.getElementById(id)) {return;}
					js = d.createElement(s); js.id = id;
					js.src = "//connect.facebook.net/en_US/sdk.js";					
					fjs.parentNode.insertBefore(js, fjs);				 	
				}(document, 'script', 'facebook-jssdk'));
			 
				</script>

				<a href="#" class="userpro-social-facebook" data-redirect="<?php 
        echo $facebook_redirect;
        ?>
" title="<?php 
        $facebook_title;
        ?>
"><i class="userpro-icon-facebook"></i><?php 
        echo $facebook_title;
        ?>
</a>

				<?php 
    }
    /* TWITTER */
    if ($twitter == 1 && userpro_get_option('twitter_connect') == 1 && userpro_get_option('twitter_consumer_key') && userpro_get_option('twitter_consumer_secret')) {
        $url = $userpro->get_twitter_auth_url();
        ?>
			
				<a href="<?php 
        echo $url;
        ?>
" class="userpro-social-twitter" title="<?php 
        echo $twitter_title;
        ?>
"><i class="userpro-icon-twitter"></i><?php 
        echo $twitter_title;
        ?>
</a>
		
				<?php 
    }
    /* GOOGLE */
    if ($google == 1 && userpro_get_option('google_connect') == 1 && userpro_get_option('google_client_id') && userpro_get_option('google_client_secret') && userpro_get_option('google_redirect_uri')) {
        $url = $userpro->get_google_auth_url();
        ?>
			
				<a href="<?php 
        echo $url;
        ?>
" class="userpro-social-google" title="<?php 
        echo $google_title;
        ?>
"><i class="userpro-icon-google-plus"></i><?php 
        echo $google_title;
        ?>
</a>
				
				<?php 
    }
    if (userpro_get_option('linkedin_connect') == 1 && userpro_get_option('linkedin_app_key') && userpro_get_option('linkedin_Secret_Key')) {
        include "linkedinPanel.php";
        ?>
			      <a id="wplLiLoginBtn"  class="userpro-social-linkedin" title="<?php 
        echo Linkedin;
        ?>
"><?php 
        echo Linkedin;
        ?>
</a>
						<?php 
    }
    /* Instagram */
    if (userpro_get_option('instagram_connect') == 1 && userpro_get_option('instagram_app_key') && userpro_get_option('instagram_Secret_Key')) {
        include "instagramPanel.php";
        ?>
				      <a id="wpInLoginBtn"  class="userpro-social-instagram" title="<?php 
        echo Instagram;
        ?>
"><?php 
        echo Instagram;
        ?>
</a>
							<?php 
    }
    /* VK */
    if ($vk == 1 && class_exists('userpro_vk_api') && userpro_vk_get_option('vk_connect') == 1 && userpro_vk_get_option('vk_api_id') && userpro_vk_get_option('vk_api_secret')) {
        global $userpro_vk;
        $url = $userpro_vk->getAuthorizeURL();
        ?>
				
				<a href="<?php 
        echo $userpro_vk->getAuthorizeURL();
        ?>
" class="userpro-social-vk" title="<?php 
        echo $vk_title;
        ?>
"><i class="userpro-icon-vk"></i><?php 
        echo $vk_title;
        ?>
</a>
				
				<?php 
    }
    do_action('userpro_social_connect_buttons_large');
    echo '</div><div class="userpro-clear"></div>';
    ?>
		
		<style type="text/css">
		div.userpro-social-big {
			margin: 0 auto;
			width: <?php 
    echo $width;
    ?>
;
		}
		
		<?php 
    if ($size == 'normal') {
        ?>
		div.userpro-social-big a {
			padding: 12px 20px;
			font-size: 16px;
		}
		<?php 
    }
    ?>
		
		<?php 
    if ($size == 'big') {
        ?>
		div.userpro-social-big a {
			padding: 20px 20px;
			font-size: 19px;
		}
		<?php 
    }
    ?>
		
		</style>
		
		<?php 
    $output = ob_get_contents();
    ob_end_clean();
    return $output;
}
Exemple #23
0
div.userpro-online-item-i,
div.userpro-online-item-i img,
div.userpro-post.userpro-post-compact div.userpro-post-img img,
a.userpro-online-i-thumb img,
div.userpro-awsm-pic img,
div.userpro-awsm-pic,
div.userpro-sc-img img
{
	border-radius: 999px !important;
}
<?php 
}
?>

<?php 
if (userpro_get_option('thumb_style') == 'square') {
    ?>
div.userpro-profile-img img,
div.userpro-pic-profilepicture img,
div.userpro-list-item-i,
div.userpro-list-item-i img,
div.userpro-online-item-i,
div.userpro-online-item-i img,
div.userpro-post.userpro-post-compact div.userpro-post-img img,
a.userpro-online-i-thumb img,
div.userpro-awsm-pic img,
div.userpro-awsm-pic,
div.userpro-sc-img img
{
	border-radius: 0px !important;
}
Exemple #24
0
 function instagram_save_profile_pic($user_id, $profilepicture, $method = null)
 {
     $method = userpro_get_option('picture_save_method');
     $unique_id = uniqid();
     update_user_meta($user_id, 'instagram_pic_url', $profilepicture);
     if ($method == 'internal') {
         $this->do_uploads_dir($user_id);
         $this->move_file($user_id, $profilepicture, $unique_id . '.jpg');
         update_user_meta($user_id, 'profilepicture', $this->get_uploads_url($user_id) . $unique_id . '.jpg');
     } else {
         update_user_meta($user_id, 'profilepicture', $profilepicture);
     }
 }
Exemple #25
0
function userpro_first_setup($rebuild = 0)
{
    global $userpro;
    $pages = get_option('userpro_pages');
    /* Rebuild */
    if ($rebuild) {
        // delete existing pages for userpro
        if (isset($pages) && is_array($pages)) {
            foreach ($pages as $page_id) {
                wp_delete_post($page_id, true);
            }
        }
        // delete from DB
        delete_option('userpro_pages');
    }
    /* Create pages if they do not exist */
    if (!isset($pages['profile'])) {
        $slug = userpro_get_option('slug');
        $slug_edit = userpro_get_option('slug_edit');
        $slug_register = userpro_get_option('slug_register');
        $slug_login = userpro_get_option('slug_login');
        $slug_directory = userpro_get_option('slug_directory');
        $slug_logout = userpro_get_option('slug_logout');
        $logout_page = array('post_title' => __('Logout', 'userpro'), 'post_content' => '', 'post_name' => $slug_logout, 'comment_status' => 'closed', 'post_type' => 'page', 'post_status' => 'publish', 'post_author' => 1);
        $logout_page = wp_insert_post($logout_page);
        $pages['logout_page'] = $logout_page;
        $post = get_post($logout_page, ARRAY_A);
        userpro_set_option('slug_logout', $post['post_name']);
        $directory_page = array('post_title' => __('Member Directory', 'userpro'), 'post_content' => '[userpro template=memberlist]', 'post_name' => $slug_directory, 'comment_status' => 'closed', 'post_type' => 'page', 'post_status' => 'publish', 'post_author' => 1);
        $directory_page = wp_insert_post($directory_page);
        $pages['directory_page'] = $directory_page;
        $post = get_post($directory_page, ARRAY_A);
        userpro_set_option('slug_directory', $post['post_name']);
        $parent = array('post_title' => __('My Profile', 'userpro'), 'post_content' => '[userpro template=view]', 'post_name' => $slug, 'comment_status' => 'closed', 'post_type' => 'page', 'post_status' => 'publish', 'post_author' => 1);
        $parent = wp_insert_post($parent);
        $pages['profile'] = $parent;
        $post = get_post($parent, ARRAY_A);
        userpro_set_option('slug', $post['post_name']);
        $edit = array('post_title' => __('Edit Profile', 'userpro'), 'post_content' => '[userpro template=edit]', 'post_name' => $slug_edit, 'comment_status' => 'closed', 'post_type' => 'page', 'post_status' => 'publish', 'post_author' => 1, 'post_parent' => $parent);
        $edit = wp_insert_post($edit);
        $pages['edit'] = $edit;
        $post = get_post($edit, ARRAY_A);
        userpro_set_option('slug_edit', $post['post_name']);
        $register = array('post_title' => __('Register', 'userpro'), 'post_content' => '[userpro template=register]', 'post_name' => $slug_register, 'comment_status' => 'closed', 'post_type' => 'page', 'post_status' => 'publish', 'post_author' => 1, 'post_parent' => $parent);
        $register = wp_insert_post($register);
        $pages['register'] = $register;
        $post = get_post($register, ARRAY_A);
        userpro_set_option('slug_register', $post['post_name']);
        $login = array('post_title' => __('Login', 'userpro'), 'post_content' => '[userpro template=login]', 'post_name' => $slug_login, 'comment_status' => 'closed', 'post_type' => 'page', 'post_status' => 'publish', 'post_author' => 1, 'post_parent' => $parent);
        $login = wp_insert_post($login);
        $pages['login'] = $login;
        $post = get_post($login, ARRAY_A);
        userpro_set_option('slug_login', $post['post_name']);
        update_option('userpro_pages', $pages);
        /* Rewrite rules */
        $slug = userpro_get_option('slug');
        $slug_edit = userpro_get_option('slug_edit');
        $slug_register = userpro_get_option('slug_register');
        $slug_login = userpro_get_option('slug_login');
        $slug_directory = userpro_get_option('slug_directory');
        $slug_logout = userpro_get_option('slug_logout');
        add_rewrite_rule("{$slug}/{$slug_register}", 'index.php?pagename=' . $slug . '/' . $slug_register, 'top');
        add_rewrite_rule("{$slug}/{$slug_login}", 'index.php?pagename=' . $slug . '/' . $slug_login, 'top');
        add_rewrite_rule("{$slug}/{$slug_edit}/([^/]+)/?", 'index.php?pagename=' . $slug . '/' . $slug_edit . '&up_username=$matches[1]', 'top');
        add_rewrite_rule("{$slug}/{$slug_edit}", 'index.php?pagename=' . $slug . '/' . $slug_edit, 'top');
        add_rewrite_rule("{$slug}/([^/]+)/?", 'index.php?pagename=' . $slug . '&up_username=$matches[1]', 'top');
        flush_rewrite_rules();
    } else {
        // pages installed
        $slug = userpro_get_option('slug');
        $slug_edit = userpro_get_option('slug_edit');
        $slug_register = userpro_get_option('slug_register');
        $slug_login = userpro_get_option('slug_login');
        $slug_directory = userpro_get_option('slug_directory');
        $slug_logout = userpro_get_option('slug_logout');
        add_rewrite_rule("{$slug}/{$slug_register}", 'index.php?pagename=' . $slug . '/' . $slug_register, 'top');
        add_rewrite_rule("{$slug}/{$slug_login}", 'index.php?pagename=' . $slug . '/' . $slug_login, 'top');
        add_rewrite_rule("{$slug}/{$slug_edit}/([^/]+)/?", 'index.php?pagename=' . $slug . '/' . $slug_edit . '&up_username=$matches[1]', 'top');
        add_rewrite_rule("{$slug}/{$slug_edit}", 'index.php?pagename=' . $slug . '/' . $slug_edit, 'top');
        add_rewrite_rule("{$slug}/([^/]+)/?", 'index.php?pagename=' . $slug . '&up_username=$matches[1]', 'top');
    }
}
Exemple #26
0
function userpro_bp_get_user_firstname($var1, $var2)
{
    $user_id = bp_displayed_user_id();
    return userpro_profile_data('display_name', $user_id);
}
// Override buddypress mention name
if (userpro_get_option('buddypress_userpro_displayname_sync')) {
    add_filter('bp_get_displayed_user_mentionname', 'userpro_bp_get_displayed_user_mentionname', 9999);
}
function userpro_bp_get_displayed_user_mentionname()
{
    $user_id = bp_displayed_user_id();
    return userpro_profile_data('display_name', $user_id);
}
// Override BuddyPress avatar
if (userpro_get_option('buddypress_userpro_avatar_sync')) {
    add_filter('bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3);
    //late load
}
function revert_to_default_wp_avatar($img, $params, $item_id)
{
    $img_width = 80;
    if ($params['object'] != 'user') {
        return $img;
    }
    remove_filter('bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3);
    if (!userpro_user_has_avatar($item_id)) {
        $width = $params['width'];
        if (false !== $width) {
            $img_width = $width;
        } elseif ('thumb' == $params['type']) {
add_action('init', function () {
    add_action('wp_title', function ($title, $sep = ' | ') {
        global $post;
        global $current_user;
        $current_user = wp_get_current_user();
        // make sure it's a page
        if ($post->post_type != 'page') {
            return $title;
        }
        // check if user loged in
        if (is_user_logged_in()) {
            return $title;
        }
        //$post = get_post($id);
        $other_username = '';
        $other_username = get_query_var('up_username');
        if (isset($post) && $post->post_name == userpro_get_option('slug') && !is_admin()) {
            global $wp_filter;
            if ($other_username != '') {
                $title = sprintf(__("%s's Profile", 'userpro-persian'), $other_username);
                $site_description = get_bloginfo('description', 'display');
                $title .= "{$sep} {$site_description}";
            } else {
                $title = sprintf(__("%s's Profile", 'userpro-persian'), $current_user->display_name);
                $site_description = get_bloginfo('description', 'display');
                $title .= "{$sep} {$site_description}";
            }
        }
        return $title;
    }, 1, 2);
});
		<td>
			<?php 
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $roles = $wp_roles->get_names();
    foreach ($roles as $k => $v) {
        ?>
			<label><input type='checkbox' value='<?php 
        echo $k;
        ?>
' name='<?php 
        echo $key;
        ?>
_roles[]' <?php 
        if (userpro_get_option($key . '_roles') && in_array($k, userpro_get_option($key . '_roles'))) {
            echo 'checked="checked"';
        }
        ?>
 />&nbsp;&nbsp;<?php 
        echo $v;
        ?>
</label>
			<?php 
    }
    ?>
		</td>
	</tr>
	<?php 
}
?>
function userpro($args = array())
{
    global $post, $wp, $userpro_admin, $userpro;
    if (is_home()) {
        $permalink = home_url();
    } else {
        if (isset($post->ID)) {
            $permalink = get_permalink($post->ID);
        } else {
            $permalink = '';
        }
    }
    /* arguments */
    $defaults = apply_filters('userpro_shortcode_args', array('template' => null, 'max_width' => userpro_get_option('width'), 'uploads_dir' => $userpro->get_uploads_url(), 'default_avatar_male' => userpro_url . 'img/default_avatar_male.jpg', 'default_avatar_female' => userpro_url . 'img/default_avatar_female.jpg', 'layout' => userpro_get_option('layout'), 'margin_top' => 0, 'margin_bottom' => '30px', 'align' => 'center', 'skin' => userpro_get_option('skin'), 'required_text' => __('This field is required', 'userpro'), 'password_too_short' => __('Your password is too short', 'userpro'), 'passwords_do_not_match' => __('Passwords do not match', 'userpro'), 'password_not_strong' => __('Password is not strong enough', 'userpro'), 'keep_one_section_open' => 1, 'allow_sections' => 1, 'permalink' => $permalink, 'field_icons' => userpro_get_option('field_icons'), 'profile_thumb_size' => 80, 'register_heading' => __('Register an Account', 'userpro'), 'register_side' => __('Already a member?', 'userpro'), 'register_side_action' => 'login', 'register_button_action' => 'login', 'register_button_primary' => __('Register', 'userpro'), 'register_button_secondary' => __('Login', 'userpro'), 'register_group' => 'default', 'register_redirect' => '', 'type' => userpro_mu_get_option('multi_forms_default'), 'login_heading' => __('Login', 'userpro'), 'login_side' => __('Forgot your password?', 'userpro'), 'login_side_action' => 'reset', 'login_button_action' => 'register', 'login_button_primary' => __('Login', 'userpro'), 'login_button_secondary' => __('Create an Account', 'userpro'), 'login_group' => 'default', 'login_redirect' => '', 'delete_heading' => __('Delete Profile', 'userpro'), 'delete_side' => __('Undo, back to profile', 'userpro'), 'delete_side_action' => 'view', 'delete_button_action' => 'view', 'delete_button_primary' => __('Confirm Deletion', 'userpro'), 'delete_button_secondary' => __('Back to Profile', 'userpro'), 'delete_group' => 'default', 'reset_heading' => __('Reset Password', 'userpro'), 'reset_side' => __('Back to Login', 'userpro'), 'reset_side_action' => 'login', 'reset_button_action' => 'change', 'reset_button_primary' => __('Request Secret Key', 'userpro'), 'reset_button_secondary' => __('Change your Password', 'userpro'), 'reset_group' => 'default', 'change_heading' => __('Change your Password', 'userpro'), 'change_side' => __('Request New Key', 'userpro'), 'change_side_action' => 'reset', 'change_button_action' => 'reset', 'change_button_primary' => __('Change my Password', 'userpro'), 'change_button_secondary' => __('Do not have a secret key?', 'userpro'), 'change_group' => 'default', 'list_heading' => __('Latest Members', 'userpro'), 'list_per_page' => 5, 'list_sortby' => 'registered', 'list_order' => 'desc', 'list_users' => '', 'list_group' => 'default', 'list_thumb' => 50, 'list_showthumb' => 1, 'list_showsocial' => 1, 'list_showbio' => 0, 'list_verified' => 0, 'list_relation' => 'or', 'online_heading' => __('Who is online now', 'userpro'), 'online_thumb' => 30, 'online_showthumb' => 1, 'online_showsocial' => 0, 'online_showbio' => 0, 'online_mini' => 1, 'online_mode' => 'vertical', 'edit_button_primary' => __('Save Changes', 'userpro'), 'edit_group' => 'default', 'view_group' => 'default', 'social_target' => '_blank', 'social_group' => 'default', 'card_width' => '250px', 'card_img_width' => '250', 'card_showbio' => 1, 'card_showsocial' => 1, 'link_target' => '_blank', 'error_heading' => __('An error has occured', 'userpro'), 'memberlist_v2' => 1, 'memberlist_v2_pic_size' => '86', 'memberlist_v2_fields' => 'age,gender,country', 'memberlist_v2_bio' => 1, 'memberlist_v2_showbadges' => 1, 'memberlist_v2_showname' => 1, 'memberlist_v2_showsocial' => 1, 'memberlist_pic_size' => '120', 'memberlist_pic_topspace' => '15', 'memberlist_pic_sidespace' => '30', 'memberlist_pic_rounded' => 1, 'memberlist_width' => '100%', 'memberlist_paginate' => 1, 'memberlist_paginate_top' => 1, 'memberlist_paginate_bottom' => 1, 'memberlist_show_name' => 1, 'memberlist_popup_view' => 0, 'memberlist_withavatar' => 0, 'memberlist_verified' => 0, 'memberlist_filters' => '', 'memberlist_default_search' => 1, 'per_page' => 12, 'sortby' => 'registered', 'order' => 'desc', 'relation' => 'and', 'search' => 1, 'show_social' => 1, 'registration_closed_side' => __('Existing member? login', 'userpro'), 'registration_closed_side_action' => 'login', 'facebook_redirect' => 'profile', 'logout_redirect' => '', 'postsbyuser_num' => '12', 'postsbyuser_types' => 'post', 'postsbyuser_mode' => 'grid', 'postsbyuser_thumb' => 50, 'postsbyuser_showthumb' => 1, 'publish_heading' => __('Add a New Post', 'userpro'), 'publish_button_primary' => __('Publish', 'userpro')));
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    if ($template) {
        static $i = 0;
        ob_start();
        /* increment wall */
        $i = rand(1, 1000);
        /* user template */
        do_action('userpro_custom_template_hook', array_merge($args, array('i' => $i)));
        switch ($template) {
            case 'publish':
                if (userpro_is_logged_in()) {
                    $user_id = get_current_user_id();
                    $layout = 'none';
                    $args['layout'] = 'none';
                    if (isset($args['deny_roles']) && !empty($args['deny_roles'])) {
                        $denied_roles = explode(',', $args['deny_roles']);
                        if ($userpro->user_role_in_array($user_id, $denied_roles)) {
                            if (locate_template('userpro/not_allowed.php') != '') {
                                include get_template_directory() . '/userpro/not_allowed.php';
                            } else {
                                include userpro_path . "templates/not_allowed.php";
                            }
                        } else {
                            if (locate_template('userpro/' . $template . '.php') != '') {
                                include get_template_directory() . '/userpro/' . $template . '.php';
                            } else {
                                include userpro_path . "templates/{$template}.php";
                            }
                        }
                    } else {
                        if (locate_template('userpro/' . $template . '.php') != '') {
                            include get_template_directory() . '/userpro/' . $template . '.php';
                        } else {
                            include userpro_path . "templates/{$template}.php";
                        }
                    }
                } else {
                    /* attempt to edit profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    add_action('userpro_pre_form_message', 'userpro_msg_login_to_post');
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                    remove_action('userpro_pre_form_message', 'userpro_msg_login_to_post');
                }
                break;
            case 'postsbyuser':
                if (isset($args['user'])) {
                    if ($args['user'] == 'author') {
                        $user_id = get_the_author_meta('ID');
                    } else {
                        $user_id = userpro_get_view_user($args['user'], 'shortcode_user');
                    }
                } else {
                    $user_id = userpro_get_view_user(get_query_var('up_username'));
                }
                $post_query = $userpro->posts_by_user($user_id, $args);
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_template_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                wp_reset_query();
                break;
            case 'online':
                $users = $userpro->onlineusers();
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_template_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                break;
            case 'request_verify':
                $userpro->new_verification_request($_POST['up_username']);
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_template_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                break;
            case 'reset':
                add_action('userpro_pre_form_message', 'userpro_msg_new_secret_key');
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_template_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                remove_action('userpro_pre_form_message', 'userpro_msg_new_secret_key');
                break;
            case 'change':
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_template_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                break;
            case 'delete':
                if (isset($args['user'])) {
                    $user_id = userpro_get_view_user($args['user'], 'shortcode_user');
                } else {
                    $user_id = userpro_get_view_user(get_query_var('up_username'));
                }
                if ($user_id == 'not_found' || $user_id == 'not_authorized') {
                    if (locate_template('userpro/' . $user_id . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $user_id . '.php';
                    } else {
                        include userpro_path . "templates/{$user_id}.php";
                    }
                } elseif ((int) $user_id) {
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                } else {
                    /* attempt to edit profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                }
                break;
            case 'memberlist':
                $users = userpro_memberlist_loop($args);
                if ($args['memberlist_v2'] == 0) {
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                } else {
                    if (locate_template('userpro/' . $template . '_v2.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '_v2.php';
                    } else {
                        include userpro_path . "templates/{$template}" . "_v2.php";
                    }
                }
                break;
            case 'list':
                $users = userpro_memberlist_listusers($args, $list_users);
                if (locate_template('userpro/' . $template . '.php') != '') {
                    include get_template_directory() . '/userpro/' . $template . '.php';
                } else {
                    include userpro_path . "templates/{$template}.php";
                }
                break;
            case 'card':
                if (isset($args['user'])) {
                    $try = get_user_by('login', $args['user']);
                    $user_id = $try->ID;
                    if ($args['user'] == 'author') {
                        $user_id = get_the_author_meta('ID');
                    }
                } else {
                    if (userpro_is_logged_in()) {
                        $user_id = get_current_user_id();
                    }
                }
                if ($user_id) {
                    $get_user = get_userdata($user_id);
                    $user = $get_user->user_login;
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                }
                break;
            case 'register':
                if (userpro_get_option('users_can_register') == 0) {
                    $template = 'registration_closed';
                    $args['template'] = 'registration_closed';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                } else {
                    if (!userpro_is_logged_in() || userpro_is_logged_in() && !userpro_get_option('show_logout_register')) {
                        if (userpro_fields_group_by_template($template, $args["{$template}_group"]) != array('')) {
                            if (locate_template('userpro/' . $template . '.php') != '') {
                                include get_template_directory() . '/userpro/' . $template . '.php';
                            } else {
                                include userpro_path . "templates/{$template}.php";
                            }
                        }
                    } else {
                        $user_id = get_current_user_id();
                        if (locate_template('userpro/logout.php') != '') {
                            include get_template_directory() . '/userpro/logout.php';
                        } else {
                            include userpro_path . "templates/logout.php";
                        }
                    }
                }
                break;
            case 'login':
                if (!userpro_is_logged_in() || userpro_is_logged_in() && !userpro_get_option('show_logout_login')) {
                    if (userpro_fields_group_by_template($template, $args["{$template}_group"]) != array('')) {
                        if (locate_template('userpro/' . $template . '.php') != '') {
                            include get_template_directory() . '/userpro/' . $template . '.php';
                        } else {
                            include userpro_path . "templates/{$template}.php";
                        }
                    }
                } else {
                    $user_id = get_current_user_id();
                    if (locate_template('userpro/logout.php') != '') {
                        include get_template_directory() . '/userpro/logout.php';
                    } else {
                        include userpro_path . "templates/logout.php";
                    }
                }
                break;
            case 'edit':
                if (userpro_get_edit_user()) {
                    $user_id = userpro_get_edit_user();
                    if ($user_id == 'not_found' || $user_id == 'not_authorized') {
                        if (locate_template('userpro/' . $user_id . '.php') != '') {
                            include get_template_directory() . '/userpro/' . $user_id . '.php';
                        } else {
                            include userpro_path . "templates/{$user_id}.php";
                        }
                    } elseif (userpro_fields_group_by_template($template, $args["{$template}_group"]) != array('')) {
                        if (locate_template('userpro/' . $template . '.php') != '') {
                            include get_template_directory() . '/userpro/' . $template . '.php';
                        } else {
                            include userpro_path . "templates/{$template}.php";
                        }
                    }
                } else {
                    /* attempt to edit profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                }
                break;
            case 'view':
                if (isset($args['user'])) {
                    if ($args['user'] == 'author') {
                        $user_id = get_the_author_meta('ID');
                    } else {
                        $user_id = userpro_get_view_user($args['user'], 'shortcode_user');
                    }
                } else {
                    $user_id = userpro_get_view_user(get_query_var('up_username'));
                }
                if ($user_id == 'not_found' || $user_id == 'not_authorized') {
                    if (locate_template('userpro/' . $user_id . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $user_id . '.php';
                    } else {
                        include userpro_path . "templates/{$user_id}.php";
                    }
                } elseif ($user_id == 'login_to_view') {
                    /* attempt to view profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                } elseif ($user_id == 'login_to_view_others') {
                    /* attempt to view profile so force redirect to same page */
                    $args['force_redirect_uri'] = 1;
                    $template = 'login';
                    $args['template'] = 'login';
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/login.php";
                    }
                } elseif (userpro_fields_group_by_template($template, $args["{$template}_group"]) != array('')) {
                    if (locate_template('userpro/' . $template . '.php') != '') {
                        include get_template_directory() . '/userpro/' . $template . '.php';
                    } else {
                        include userpro_path . "templates/{$template}.php";
                    }
                }
                break;
        }
        /**
        		START THEMING
        		**/
        if (in_array($align, array('left', 'right'))) {
            echo '<div class="userpro-clear"></div>';
        }
        if (class_exists('userpro_sk_api') && is_dir(userpro_sk_path . 'skins/' . $skin)) {
            wp_register_style('userpro_skin_min', userpro_sk_url . 'skins/' . $skin . '/style.css');
            wp_enqueue_style('userpro_skin_min');
        } else {
            wp_register_style('userpro_skin_min', userpro_url . 'skins/' . $skin . '/style.css');
            wp_enqueue_style('userpro_skin_min');
        }
        if (locate_template('userpro/skins/' . $skin . '/style.css')) {
            wp_register_style('userpro_skin_custom', get_template_directory_uri() . '/userpro/skins/' . $skin . '/style.css');
            wp_enqueue_style('userpro_skin_custom');
        }
        include userpro_path . "css/userpro.php";
        /**
        			END THEMING
        		**/
        $output = ob_get_contents();
        ob_end_clean();
        return $output;
    }
}
function userpro_logout_page()
{
    global $userpro;
    if (is_page() || is_single()) {
        global $post;
        $pages = get_option('userpro_pages');
        if ($post->ID == $pages['logout_page']) {
            if (userpro_is_logged_in()) {
                $logout = userpro_get_option('logout_uri');
                if ($logout == 1) {
                    $url = home_url();
                }
                if ($logout == 2) {
                    $url = $userpro->permalink(0, 'login');
                }
                if ($logout == 3) {
                    $url = userpro_get_option('logout_uri_custom');
                }
                if (isset($_REQUEST['redirect_to'])) {
                    $url = $_REQUEST['redirect_to'];
                }
                wp_logout();
                wp_redirect($url);
                exit;
            } else {
                wp_redirect($userpro->permalink(0, 'login'));
                exit;
            }
        }
    }
}