Ejemplo n.º 1
0
function SOF_set_comment_karma()
{
    global $wpdb, $current_user;
    if (!$_POST || !isset($_POST["commentID"]) || empty($_POST["commentID"])) {
        return;
    }
    $comment_id = $_POST["commentID"];
    // Cogemos datos del usuario
    get_currentuserinfo();
    $user_ID = $current_user->ID;
    if ($user_ID == 0 && get_option('SOF_register') == 'true') {
        die("Debes registrarte para poder votar");
    } else {
        if ($user_ID == 0) {
            $user_ID = str_replace(array('.', ':', ' '), "", SOF_getIp());
        }
    }
    $karma = get_usermeta($user_ID, "karma");
    // No puedes votarte a ti mismo.
    $sql = $wpdb->prepare("SELECT user_id FROM {$wpdb->comments} WHERE comment_ID = %d LIMIT 1", $comment_id);
    $commentUser = $wpdb->get_var($sql);
    if ($user_ID == (int) $commentUser) {
        die("No te puede votar a ti mismo");
    }
    // No puedes votar 2 veces
    if (get_usermeta($user_ID, "vote_" . $comment_id) == true) {
        die("No puedes votar dos veces el mismo comentario");
    }
    // Añadimos voto
    $newKarma = 1;
    // + $karma;
    if ($_POST["vote"] === '+') {
        $query = $wpdb->prepare("UPDATE {$wpdb->comments} SET comment_karma = comment_karma + {$newKarma} WHERE comment_ID = %d LIMIT 1", $comment_id);
    } else {
        if ($_POST["vote"] == '-') {
            $query = $wpdb->prepare("UPDATE {$wpdb->comments} SET comment_karma = comment_karma - {$newKarma} WHERE comment_ID = %d LIMIT 1", $comment_id);
        } else {
            return;
        }
    }
    $wpdb->query($query);
    // KARMA COMMENT
    if ($commentUser) {
        $karmaCommentUser = get_usermeta($commentUser, "karma");
        if ($_POST["vote"] === '+') {
            update_usermeta($commentUser, "karma", $karmaCommentUser + get_option('SOF_bonoOK'));
        } else {
            if ($_POST["vote"] === '-') {
                update_usermeta($commentUser, "karma", $karmaCommentUser + get_option('SOF_bonoKO'));
            }
        }
    }
    // Karma Voto
    if ($user_ID) {
        update_usermeta($user_ID, "karma", $karma + get_option('SOF_bonoVOTE'));
        update_usermeta($user_ID, "vote_" . $comment_id, true);
    }
    wp_redirect('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    exit;
}
Ejemplo n.º 2
0
function affiliate_new_subscription($tosub_id, $tolevel_id, $to_order, $user_id)
{
    if (function_exists('get_user_meta')) {
        $aff = get_user_meta($user_id, 'affiliate_referred_by', true);
        $paid = get_user_meta($user_id, 'affiliate_paid', true);
    } else {
        $aff = get_usermeta($user_id, 'affiliate_referred_by');
        $paid = get_usermeta($user_id, 'affiliate_paid');
    }
    if (empty($aff)) {
        $aff = false;
    }
    if ($aff && $paid != 'yes') {
        $whole = get_option("membership_whole_payment_" . $tosub_id, 0);
        $partial = get_option("membership_partial_payment_" . $tosub_id, 0);
        if (!empty($whole) || !empty($partial)) {
            $amount = $whole . '.' . $partial;
        } else {
            $amount = 0;
        }
        do_action('affiliate_purchase', $aff, $amount);
        if (defined('AFFILIATE_PAYONCE') && AFFILIATE_PAYONCE == 'yes') {
            if (function_exists('update_user_meta')) {
                update_user_meta($user_id, 'affiliate_paid', 'yes');
            } else {
                update_usermeta($user_id, 'affiliate_paid', 'yes');
            }
        }
    }
}
function id_get_user_meta($id, $val)
{
    if (function_exists('get_user_meta')) {
        return get_user_meta($id, $val, true);
    }
    return get_usermeta($id, $val);
}
/**
 * xprofile_record_wire_post_notification()
 *
 * Records a notification for a new profile wire post to the database and sends out a notification
 * email if the user has this setting enabled.
 * 
 * @package BuddyPress XProfile
 * @param $wire_post_id The ID of the wire post
 * @param $user_id The id of the user that the wire post was sent to
 * @param $poster_id The id of the user who wrote the wire post
 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
 * @global $current_user WordPress global variable containing current logged in user information
 * @uses bp_is_home() Returns true if the current user being viewed is equal the logged in user
 * @uses get_usermeta() Get a user meta value based on meta key from wp_usermeta
 * @uses BP_Wire_Post Class Creates a new wire post object based on ID.
 * @uses site_url Returns the site URL
 * @uses wp_mail Sends an email
 */
function xprofile_record_wire_post_notification($wire_post_id, $user_id, $poster_id)
{
    global $bp, $current_user;
    if ($bp->current_component == $bp->wire->slug && !bp_is_home()) {
        bp_core_add_notification($poster_id, $user_id, 'xprofile', 'new_wire_post');
        if (!get_usermeta($bp->loggedin_user->id, 'notification_profile_wire_post') || 'yes' == get_usermeta($bp->loggedin_user->id, 'notification_profile_wire_post')) {
            $poster_name = bp_fetch_user_fullname($poster_id, false);
            $wire_post = new BP_Wire_Post($bp->profile->table_name_wire, $wire_post_id, true);
            $ud = get_userdata($user_id);
            $wire_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/wire';
            $settings_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications';
            // Set up and send the message
            $to = $ud->user_email;
            $subject = '[' . get_blog_option(1, 'blogname') . '] ' . sprintf(__('%s posted on your wire.', 'buddypress'), stripslashes($poster_name));
            $message = sprintf(__('%s posted on your wire:

"%s"

To view your wire: %s

---------------------
', 'buddypress'), $poster_name, stripslashes($wire_post->content), $wire_link);
            $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
            // Send it
            wp_mail($to, $subject, $message);
        }
    }
}
Ejemplo n.º 5
0
function Medieteknik_post_tweet($tweet, $hashtag)
{
    //get current user
    global $user_ID;
    get_currentuserinfo();
    //get the saved token for this user
    $token = get_usermeta($user_ID, 'twitter_token');
    $secret = get_usermeta($user_ID, 'twitter_token_secret');
    $oauth = new TwitterOAuth($token, $secret);
    $url = 'http://api.twitter.com/1/statuses/update.xml';
    if ($hashtag && strpos(strtolower($tweet), '#medieteknik') == false) {
        //add the hashtag
        $tweet = rtrim($tweet) . ' #medieteknik';
    }
    $params = array('status' => $tweet);
    $reply = $oauth->oauth_request($url, 'POST', $params);
    //Check our request came out ok
    if ($reply['status'] != 200) {
        if ($reply['status'] == 403) {
            die('Twitter tillåter endast 150 statusuppdateringar i timmen. Försök igen senare');
        } else {
            die('Något är galet med twitter. Försök igen senare eller kontakta sidansvarig');
        }
    }
    header('location: index.php');
}
Ejemplo n.º 6
0
 /**
  * This function will add the expiration date to the users table
  * 
  * @return string
  */
 function user_columns($empty, $column, $userid)
 {
     //in case we want to add more columns later
     switch ($column) {
         case 'subscription_expiration':
             return get_usermeta($userid, 'subscription_expiration');
             break;
         case 'subscription_startdate':
             return get_usermeta($userid, 'subscription_startdate');
             break;
         case 'subscription_name':
             return get_usermeta($userid, 'subscription_name');
             break;
         case 'subscription_streetaddress':
             return get_usermeta($userid, 'subscription_streetaddress');
             break;
         case 'subscription_city':
             return get_usermeta($userid, 'subscription_city');
             break;
         case 'subscription_state':
             return get_usermeta($userid, 'subscription_state');
             break;
         case 'subscription_zip':
             return get_usermeta($userid, 'subscription_zip');
             break;
         case 'subscription_country':
             return get_usermeta($userid, 'subscription_country');
             break;
     }
     return '';
 }
    function action_show_user_profile($user)
    {
        if (function_exists('get_user_meta')) {
            $tweetbutton_twitter = get_user_meta($user->ID, 'tweetbutton_twitter', true);
            $tweetbutton_twitter_desc = get_user_meta($user->ID, 'tweetbutton_twitter_desc', true);
        } else {
            $tweetbutton_twitter = get_usermeta($user->ID, 'tweetbutton_twitter');
            $tweetbutton_twitter_desc = get_usermeta($user->ID, 'tweetbutton_twitter_desc');
        }
        ?>
    <h3>Twitter Info (Will be used on WP-TweetButton)</h3>

    <table class="form-table">
    <tr>
        <th><label for="tweetbutton_twitter">Twitter User name</label></th> 
        <td><input type="text" name="tweetbutton_twitter" id="tweetbutton_twitter" value="<?php 
        echo esc_attr($tweetbutton_twitter);
        ?>
" />
        <td><span class="description">Please enter your Twitter username.Don't add a link or @</span></td>
    </tr>
        <tr>
        <th><label for="tweetbutton_twitter_desc">Twitter Bio</label></th>
        <td><input type="text" name="tweetbutton_twitter_desc" id="tweetbutton_twitter_desc" value="<?php 
        echo esc_attr($tweetbutton_twitter_desc);
        ?>
" />
        <td><span class="description">Please enter a small Bio, ideally your Twitter Bio</span></td>
    </tr>
    </table>
    <?php 
    }
function friends_notification_accepted_request($friendship_id, $initiator_id, $friend_id)
{
    global $bp;
    $friendship = new BP_Friends_Friendship($friendship_id, false, false);
    $friend_name = bp_fetch_user_fullname($friend_id, false);
    if ('no' == get_usermeta((int) $initiator_id, 'notification_friends_friendship_accepted')) {
        return false;
    }
    $ud = get_userdata($initiator_id);
    $friend_ud = get_userdata($friend_id);
    $friend_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $friend_ud->user_login;
    $settings_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications';
    // Set up and send the message
    $to = $ud->user_email;
    $subject = '[' . get_blog_option(1, 'blogname') . '] ' . sprintf(__('%s accepted your friendship request', 'buddypress'), $friend_name);
    $message = sprintf(__('%s accepted your friend request.

To view %s\'s profile: %s

---------------------
', 'buddypress'), $friend_name, $friend_name, $friend_link);
    $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
    // Send it
    wp_mail($to, $subject, $message);
}
Ejemplo n.º 9
0
 function get_user_meta($user_ID, $meta_key)
 {
     if (function_exists('get_user_meta')) {
         return get_user_meta($user_ID, $meta_key, true);
     } else {
         return get_usermeta($user_ID, $meta_key);
     }
 }
function login_site_redirect($redirect_to)
{
    global $user;
    $primary_blog_id = get_usermeta($user->ID, 'primary_blog');
    $blog_details = get_blog_details($primary_blog_id);
    $redirect_url = $blog_details->siteurl;
    return $redirect_url;
}
Ejemplo n.º 11
0
function bp_forums_setup()
{
    global $bp, $bbpress_live;
    if ('' == get_usermeta($bp->loggedin_user->id, 'bb_capabilities')) {
        bp_forums_make_user_active_member($bp->loggedin_user->id);
    }
    $bp->version_numbers->forums = BP_FORUMS_VERSION;
}
 function testUpdateUserPerms()
 {
     $admin = new WhatDidTheySayAdmin();
     $admin->_set_up_capabilities();
     update_usermeta(1, 'transcript_capabilities', array('submit_transcriptions' => true));
     $admin->_update_user_perms(1, array('approve_transcriptions' => 'yes'));
     $this->assertEquals(array('approve_transcriptions' => true), get_usermeta(1, 'transcript_capabilities'));
 }
Ejemplo n.º 13
0
function cf_affiliate_new_paid($affiliate_settings, $user_id, $billing_type)
{
    global $blog_id, $site_id;
    if (empty($user_id)) {
        $user_id = get_current_user_id();
    }
    //echo 'in '. __FILE__ .': '. __FUNCTION__ .': '. __LINE__ .'<br />';
    //echo "affiliate_settings<pre>"; print_r($affiliate_settings); echo "</pre>";
    //echo "user_id[". $user_id ."]<br />";
    //echo "billing_type[". $billing_type ."<br />";
    //die();
    if (function_exists('get_user_meta')) {
        $aff = get_user_meta($user_id, 'affiliate_referred_by', true);
        $paid = get_user_meta($user_id, 'affiliate_paid', true);
    } else {
        $aff = get_usermeta($user_id, 'affiliate_referred_by');
        $paid = get_usermeta($user_id, 'affiliate_paid');
    }
    //echo "aff[". $aff ."]<br />";
    //echo "paid[". $paid ."]<br />";
    if (empty($aff)) {
        $aff = false;
    }
    if ($aff && $paid != 'yes') {
        if ('recurring' == $billing_type) {
            $whole = isset($affiliate_settings['cf_recurring_whole_payment']) ? $affiliate_settings['cf_recurring_whole_payment'] : '0';
            $partial = isset($affiliate_settings['cf_recurring_partial_payment']) ? $affiliate_settings['cf_recurring_partial_payment'] : '0';
            $note = __('Classifieds recurring', 'affiliate');
        } elseif ('one_time' == $billing_type) {
            $whole = isset($affiliate_settings['cf_one_time_whole_payment']) ? $affiliate_settings['cf_one_time_whole_payment'] : '0';
            $partial = isset($affiliate_settings['cf_one_time_partial_payment']) ? $affiliate_settings['cf_one_time_partial_payment'] : '0';
            $note = __('Classifieds one time', 'affiliate');
        } else {
            $whole = '0';
            $partial = '0';
            $note = __('Classifieds', 'affiliate') . ' ' . $billing_type;
        }
        //echo "whole[". $whole ."]<br />";
        //echo "partial[". $partial ."]<br />";
        if (!empty($whole) || !empty($partial)) {
            $amount = $whole . '.' . $partial;
        } else {
            $amount = 0;
        }
        if ($amount > 0) {
            //echo "amount[". $amount ."]<br />";
            $meta = array('affiliate_settings' => affiliate_settings, 'user_id' => $user_id, 'billing_type' => $billing_type, 'blog_id' => $blog_id, 'site_id' => $site_id, 'current_user_id' => get_current_user_id(), 'LOCAL_URL' => (is_ssl() ? 'https://' : 'http://') . esc_attr($_SERVER['HTTP_HOST']) . esc_attr($_SERVER['REQUEST_URI']), 'IP' => isset($_SERVER['HTTP_X_FORWARD_FOR']) ? esc_attr($_SERVER['HTTP_X_FORWARD_FOR']) : esc_attr($_SERVER['REMOTE_ADDR']));
            do_action('affiliate_purchase', $aff, $amount, 'paid:classifieds', $user_id, $note, $meta);
            if (defined('AFFILIATE_PAYONCE') && AFFILIATE_PAYONCE == 'yes') {
                if (function_exists('update_user_meta')) {
                    update_user_meta($user_id, 'affiliate_paid', 'yes');
                } else {
                    update_usermeta($user_id, 'affiliate_paid', 'yes');
                }
            }
        }
    }
}
Ejemplo n.º 14
0
function wiziapp_handle_column($curr_val, $column_name, $user_id)
{
    if (strpos($column_name, 'wiziapp_') !== FALSE) {
        $val = get_usermeta($user_id, $column_name);
        return $val != '' ? $val : 'NO';
    }
    // We are here so it wasn't our column, return the current value
    return $curr_val;
}
Ejemplo n.º 15
0
function pf_get_vars($id)
{
    $uinfo = get_userdata($id);
    foreach ($uinfo as $key => $value) {
        $vars[$key] = $value;
    }
    //let's see if this works any better than strictly using $vars['wp_capabilities']
    $vars['wp_capabilities'] = get_usermeta($id, 'wp_capabilities');
    return $vars;
}
 protected function constantTest()
 {
     $time = microtime(true);
     for ($i = 0; $i < $this->runNumber; $i++) {
         $user_id = 1;
         get_usermeta($user_id);
     }
     $time = microtime(true) - $time;
     $this->enterResult($time);
 }
Ejemplo n.º 17
0
 /**
  * populate()
  *
  * Populate the instantiated class with data based on the User ID provided.
  * 
  * @package BuddyPress Core
  * @global $userdata WordPress user data for the current logged in user.
  * @uses bp_core_get_userurl() Returns the URL with no HTML markup for a user based on their user id
  * @uses bp_core_get_userlink() Returns a HTML formatted link for a user with the user's full name as the link text
  * @uses bp_core_get_user_email() Returns the email address for the user based on user ID
  * @uses get_usermeta() WordPress function returns the value of passed usermeta name from usermeta table
  * @uses bp_core_get_avatar() Returns HTML formatted avatar for a user
  * @uses bp_profile_last_updated_date() Returns the last updated date for a user.
  */
 function populate()
 {
     $this->user_url = bp_core_get_userurl($this->id);
     $this->user_link = bp_core_get_userlink($this->id);
     $this->fullname = bp_fetch_user_fullname($this->id, false);
     $this->email = bp_core_get_user_email($this->id);
     $this->last_active = bp_core_get_last_activity(get_usermeta($this->id, 'last_activity'), __('active %s ago', 'buddypress'));
     $this->avatar = bp_core_get_avatar($this->id, 2);
     $this->avatar_thumb = bp_core_get_avatar($this->id, 1);
     $this->avatar_mini = bp_core_get_avatar($this->id, 1, 25, 25, false);
 }
Ejemplo n.º 18
0
function rwi_user_profile_website_action($user_id)
{
    $website = get_usermeta($user_id, 'user_url');
    if ($website) {
        $status = true;
    } else {
        $status = false;
    }
    global $SimpleCondition;
    $SimpleCondition->check('rwi_user_profile_website', $user_id, $status);
}
Ejemplo n.º 19
0
function messages_ajax_close_notice()
{
    global $userdata;
    if (!isset($_POST['notice_id'])) {
        echo "-1[[split]]" . __('There was a problem closing the notice.', 'buddypress');
    } else {
        $notice_ids = get_usermeta($userdata->ID, 'closed_notices');
        $notice_ids[] = (int) $_POST['notice_id'];
        update_usermeta($userdata->ID, 'closed_notices', $notice_ids);
    }
}
function wpsc_display_product_form($product_id = 0)
{
    global $wpdb, $wpsc_product_defaults;
    $product_id = absint($product_id);
    //$variations_processor = new nzshpcrt_variations;
    if ($product_id > 0) {
        $product_data = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id`='{$product_id}' LIMIT 1", ARRAY_A);
        $product_data['meta']['dimensions'] = get_product_meta($product_id, 'dimensions', true);
        $product_data['meta']['external_link'] = get_product_meta($product_id, 'external_link', true);
        $product_data['meta']['merchant_notes'] = get_product_meta($product_id, 'merchant_notes', true);
        $product_data['meta']['sku'] = get_product_meta($product_id, 'sku', true);
        $product_data['meta']['hires_url'] = get_product_meta($product_id, 'hires_url', true);
        $product_data['meta']['engrave'] = get_product_meta($product_id, 'engraved', true);
        $product_data['meta']['can_have_uploaded_image'] = get_product_meta($product_id, 'can_have_uploaded_image', true);
        $product_data['meta']['table_rate_price'] = get_product_meta($product_id, 'table_rate_price', true);
        $sql = "SELECT `meta_key`, `meta_value` FROM " . WPSC_TABLE_PRODUCTMETA . " WHERE `meta_key` LIKE 'currency%' AND `product_id`=" . $product_id;
        $product_data['newCurr'] = $wpdb->get_results($sql, ARRAY_A);
        //echo "<pre>".print_r($product_data,true)."</pre>";
        if (function_exists('wp_insert_term')) {
            $term_relationships = $wpdb->get_results("SELECT * FROM `{$wpdb->term_relationships}` WHERE object_id = '{$product_id}'", ARRAY_A);
            foreach ((array) $term_relationships as $term_relationship) {
                $tt_ids[] = $term_relationship['term_taxonomy_id'];
            }
            foreach ((array) $tt_ids as $tt_id) {
                $term_ids[] = $wpdb->get_var("SELECT `term_id` FROM `{$wpdb->term_taxonomy}` WHERE `term_taxonomy_id` = '{$tt_id}' AND `taxonomy` = 'product_tag' LIMIT 1");
            }
            foreach ((array) $term_ids as $term_id) {
                if ($term_id != NULL) {
                    $tags[] = $wpdb->get_var("SELECT `name` FROM `{$wpdb->terms}` WHERE `term_id`='{$term_id}' LIMIT 1");
                }
            }
            if ($tags != NULL) {
                $imtags = implode(',', $tags);
            }
        }
        //exit('got called<pre>'.print_r($imtags,true).'</pre>');
        $check_variation_value_count = $wpdb->get_var("SELECT COUNT(*) as `count` FROM `" . WPSC_TABLE_VARIATION_VALUES_ASSOC . "` WHERE `product_id` = '{$product_id}'");
    } else {
        if (isset($_SESSION['wpsc_failed_product_post_data']) && count($_SESSION['wpsc_failed_product_post_data']) > 0) {
            $product_data = array_merge($wpsc_product_defaults, $_SESSION['wpsc_failed_product_post_data']);
            $_SESSION['wpsc_failed_product_post_data'] = null;
        } else {
            $product_data = $wpsc_product_defaults;
        }
    }
    $product_data = apply_filters('wpsc_display_product_form_get', $product_data);
    $current_user = wp_get_current_user();
    // we put the closed postboxes array into the product data to propagate it to each form without having it global.
    $product_data['closed_postboxes'] = (array) get_usermeta($current_user->ID, 'closedpostboxes_store_page_wpsc-edit-products');
    $product_data['hidden_postboxes'] = (array) get_usermeta($current_user->ID, 'metaboxhidden_store_page_wpsc-edit-products');
    if (count($product_data) > 0) {
        wpsc_product_basic_details_form($product_data);
    }
}
Ejemplo n.º 21
0
function membership_is_active($userdata, $password)
{
    global $nxtdb;
    // Checks if this member is an active one.
    if (!empty($userdata) && !is_nxt_error($userdata)) {
        $id = $userdata->ID;
        if (get_usermeta($id, $nxtdb->prefix . 'membership_active', true) == 'no') {
            return new nxt_Error('member_inactive', __('Sorry, this account is not active.', 'membership'));
        }
    }
    return $userdata;
}
Ejemplo n.º 22
0
 public function got_new_badge()
 {
     if (!$this->gotbadge) {
         return false;
     }
     $badges = get_usermeta($this->who_id, 'new_badges');
     if ($badges && is_array($badges)) {
         $badges[] = $this->gotbadge;
         update_usermeta($this->who_id, 'new_badges', $badges);
     }
     return $this->gotbadge;
 }
Ejemplo n.º 23
0
function sfc_login_profile_page($profile)
{
    $options = get_option('sfc_options');
    ?>
	<table class="form-table">
		<tr>
			<th><label><?php 
    _e('Facebook Connect', 'sfc');
    ?>
</label></th>
<?php 
    $fbuid = get_usermeta($profile->ID, 'fbuid');
    if (empty($fbuid)) {
        ?>
			<td><p><fb:login-button perms="email,offline_access" v="2" size="large" onlogin="******"><fb:intl><?php 
        _e('Connect this WordPress account to Facebook', 'sfc');
        ?>
</fb:intl></fb:login-button></p></td>
		</tr>
	</table>
	<?php 
    } else {
        ?>
		<td><p><?php 
        _e('Connected as', 'sfc');
        ?>
		<fb:profile-pic size="square" width="32" height="32" uid="<?php 
        echo $fbuid;
        ?>
" linked="true"></fb:profile-pic>
		<fb:name useyou="false" uid="<?php 
        echo $fbuid;
        ?>
"></fb:name>.
<?php 
        if (SFC_ALLOW_DISCONNECT) {
            ?>
		<input type="button" class="button-primary" value="<?php 
            _e('Disconnect this account from WordPress', 'sfc');
            ?>
" onclick="sfc_login_update_fbuid(1); return false;" />
<?php 
        }
        ?>
		</p></td>
	<?php 
    }
    ?>
	</tr>
	</table>
	<?php 
}
Ejemplo n.º 24
0
function primary_user_of_blog($blog_id)
{
    $users = get_users_of_blog($blog_id);
    foreach ($users as $user) {
        if (get_usermeta($user->user_id, 'primary_blog') == $blog_id) {
            return $user;
        }
        switch_to_blog($blog_id);
        $user_o = new WP_User($user->user_id);
        if ($user_o->has_cap('administrator') && strcmp($user->user_nicename, "admin") != 0) {
            $result = $user;
        }
        restore_current_blog();
    }
    return $result;
}
Ejemplo n.º 25
0
function bp_em_screen_settings_menu_content()
{
    global $bp, $bp_settings_updated;
    ?>

		<?php 
    if ($bp_settings_updated) {
        ?>
			<div id="message" class="updated fade">
				<p><?php 
        _e('Changes Saved.', 'bp-em');
        ?>
</p>
			</div>
		<?php 
    }
    ?>

		<form action="<?php 
    echo $bp->loggedin_user->domain . 'settings/events-settings/';
    ?>
" name="bp-em-admin-form" id="account-delete-form" class="bp-em-admin-form" method="post">

			<input type="checkbox" name="bp-em-option-one" id="bp-em-option-one" value="1"<?php 
    if ('1' == get_usermeta($bp->loggedin_user->id, 'bp-em-option-one')) {
        ?>
 checked="checked"<?php 
    }
    ?>
 /> <?php 
    _e('Do you love clicking checkboxes?', 'bp-em');
    ?>
			<p class="submit">
				<input type="submit" value="<?php 
    _e('Save Settings', 'bp-em');
    ?>
 &raquo;" id="submit" name="submit" />
			</p>

			<?php 
    /* This is very important, don't leave it out. */
    wp_nonce_field('bp-em-admin');
    ?>

		</form>
	<?php 
}
 /**
  * Get a user preference
  *
  * @since 0.1.0
  *
  * @param  int     $user_id
  * @param  string  $key
  *
  * @return mixed
  */
 function wp_get_user_preference($user_id = 0, $key = '')
 {
     // Get user/site/network preference map
     $keys = wp_map_user_preference_key($key);
     // Check usermeta first
     $retval = get_usermeta($user_id, $keys['user']);
     // Nothing, so check site option
     if (false === $retval) {
         $retval = get_option($keys['site']);
         // Nothing, so check network option if multisite
         if (false === $retval && is_multisite()) {
             $retval = get_site_option($keys['network']);
         }
     }
     // Filter & return
     return apply_filters('wp_get_user_preference', $retval, $user_id, $key);
 }
Ejemplo n.º 27
0
	/**
	 * Construct a pager object using the $_GET data, the current URL, and default preferences
	 *
	 * @param array $data Array of values, typically from $_GET
	 * @param string $url The current URL
	 * @param string $orderby Default database column to order data by
	 * @param string $direction Default direction of ordering (DESC or ASC)
	 * @param string $id An ID for the pager to separate it from other pagers (typically the plugin name)
	 * @return void
	 **/
	function Search_Pager ($data, $url, $orderby = '', $direction = 'DESC', $id = 'default', $tags = '')
	{
		// Remove all pager params from the url
		$this->id  = $id;
		$this->url = $url;
		
		if (isset ($data['curpage']))
			$this->current_page = intval ($data['curpage']);

		global $user_ID;
		$per_page = get_usermeta ($user_ID, 'ug_per_page');
		if (isset ($data['perpage']))
		{
			$this->per_page = intval ($data['perpage']);
			$per_page[get_class ($this)][$this->id] = $this->per_page;
			
			update_usermeta ($user_ID, 'ug_per_page', $per_page);
		}
		else if (isset ($per_page[get_class ($this)]) && isset ($per_page[get_class ($this)][$this->id]))
			$this->per_page = $per_page[get_class ($this)][$this->id];

		if ($orderby != '')
			$this->order_by = $orderby;
		
		if (isset ($data['orderby']))
			$this->order_by = $data['orderby'];
		
		if (!empty ($tags))
		{
			$this->order_tags = $tags;
			if (isset ($this->order_tags[$this->order_by]))
				$this->order_by = $this->order_tags[$this->order_by];
		}

		$this->order_direction = $direction;
		$this->order_original  = $orderby;
		if (isset ($data['order']))
			$this->order_direction = $data['order'];
		
		$this->search = isset($data['search']) ? $data['search'] : '';
		$this->steps = array (10, 25, 50, 100, 250);
		$this->url = str_replace ('&', '&amp;', $this->url);
		$this->url = str_replace ('&&amp;', '&amp;', $this->url);
	}
function apply_user_defaults($user_id)
{
    // fetch current user meta information
    $first = get_usermeta($user_id, 'first_name');
    $last = get_usermeta($user_id, 'last_name');
    $nick = get_usermeta($user_id, 'nickname');
    $display = "";
    // set the default display name
    $display_type = get_option('user_defaults_display_name');
    switch ($display_type) {
        case "first_last":
            $display = $first . " " . $last;
            break;
        case "last_first":
            $display = $last . " " . $first;
            break;
        case "first":
            $display = $first;
            break;
        case "last":
            $display = $last;
            break;
        case "nick":
            $display = $nick;
            break;
    }
    wp_update_user(array("ID" => $user_id, "display_name" => $display));
    // set the administrative interface color
    $admin_color = get_option('user_defaults_admin_color');
    wp_update_user(array("ID" => $user_id, "admin_color" => $admin_color));
    // set the rich editor default (true = disabled)
    if ((bool) get_option('user_defaults_rich_editing')) {
        update_usermeta($user_id, 'rich_editing', 'false');
    } else {
        update_usermeta($user_id, 'rich_editing', 'true');
    }
    // set the keyboard shortcuts
    if ((bool) get_option('user_defaults_comments_shortcuts')) {
        update_usermeta($user_id, 'comment_shortcuts', 'true');
    } else {
        update_usermeta($user_id, 'comment_shortcuts', 'false');
    }
}
Ejemplo n.º 29
0
    function replace_choco_theme_icon()
    {
        global $current_user;
        get_currentuserinfo();
        $color_scheme = get_usermeta($current_user, 'admin_color');
        $icons_root = get_bloginfo('stylesheet_directory') . '/lib/images/';
        $this->icon = "{$icons_root}choco-icon-{$color_scheme}.gif";
        ?>
		<script type="text/javascript" charset="utf-8">
			jQuery(function () {
			    jQuery('.toplevel_page_theme-options').find('.wp-menu-image img').attr('src', '<?php 
        echo $this->icon;
        ?>
');
			});
			
		</script>
		<?php 
    }
/**
 * Notification functions are used to send email notifications to users on specific events
 * They will check to see the users notification settings first, if the user has the notifications
 * turned on, they will be sent a formatted email notification. 
 *
 * You should use your own custom actions to determine when an email notification should be sent.
 */
function bp_zoneideas_send_high_five_notification($to_user_id, $from_user_id)
{
    global $bp;
    /* Let's grab both user's names to use in the email. */
    $sender_name = bp_fetch_user_fullname($from_user_id, false);
    $reciever_name = bp_fetch_user_fullname($to_user_id, false);
    /* We need to check to see if the recipient has opted not to recieve high-five emails */
    if ('no' == get_usermeta((int) $to_user_id, 'notification_zoneideas_new_high_five')) {
        return false;
    }
    /* Get the userdata for the reciever and sender, this will include usernames and emails that we need. */
    $reciever_ud = get_userdata($to_user_id);
    $sender_ud = get_userdata($from_user_id);
    if (!$bp->profile->slug) {
        $bp->profile->slug = 'profile';
    }
    /* Now we need to construct the URL's that we are going to use in the email */
    $sender_profile_link = site_url(MEMBERS_SLUG . '/' . $sender_ud->user_login . '/' . $bp->profile->slug);
    $sender_highfive_link = site_url(MEMBERS_SLUG . '/' . $sender_ud->user_login . '/' . $bp->zoneideas->slug . '/screen-one');
    $reciever_settings_link = site_url(MEMBERS_SLUG . '/' . $reciever_ud->user_login . '/settings/notifications');
    /* Set up and send the message */
    $to = $reciever_ud->user_email;
    $subject = sprintf(__('%s high-fived you!', 'bp-zoneideas'), $sender_name);
    $message = sprintf(__('%s sent you a high-five! Why not send one back?

To see %s\'s profile: %s

To send %s a high five: %s

---------------------
', 'bp-zoneideas'), $sender_name, $sender_name, $sender_profile_link, $sender_name, $sender_highfive_link);
    $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'bp-zoneideas'), $reciever_settings_link);
    // Send it!
    wp_mail($to, $subject, $message);
}