public function load_user()
 {
     if ($this->id > 0) {
         $current_user = get_user_by('ID', $this->id);
     } elseif (function_exists('is_user_logged_in') && is_user_logged_in()) {
         $current_user = wp_get_current_user();
     }
     if (isset($current_user) && $current_user) {
         $this->id = $current_user->ID;
         $this->first_name = $current_user->user_firstname;
         $this->last_name = $current_user->user_lastname;
         $this->email = $current_user->user_email;
         $this->address = get_user_meta($current_user->ID, 'address', TRUE);
         $this->is_on_mailing_list = get_user_meta($current_user->ID, 'mailing_list', TRUE);
         $this->is_on_mailing_list = $this->is_on_mailing_list == 1 ? TRUE : FALSE;
         $neighborhood_id = get_user_meta($current_user->ID, 'neighborhood_id', TRUE);
         if (!empty($neighborhood_id) && $neighborhood_id > 0) {
             $args = array('post_type' => 'wbb_neighborhood', 'post_status' => 'publish');
             $query = new \WP_Query($args);
             while ($query->have_posts()) {
                 $query->the_post();
                 if (get_the_ID() == $neighborhood_id) {
                     $this->neighborhood = new Neighborhood();
                     $this->neighborhood->post_id = get_the_ID();
                     $this->neighborhood->title = get_the_title();
                     break;
                 }
             }
         }
         $this->get_locations();
     }
 }
 /**
  * Check if the user has dismissed a notification
  *
  * @param Yoast_Notification $notification The notification to check for dismissal.
  * @param null|int           $user_id      User ID to check on.
  *
  * @return bool
  */
 public static function is_notification_dismissed(Yoast_Notification $notification, $user_id = null)
 {
     $user_id = !is_null($user_id) ? $user_id : get_current_user_id();
     $dismissal_key = $notification->get_dismissal_key();
     $current_value = get_user_meta($user_id, $dismissal_key, $single = true);
     return !empty($current_value);
 }
Example #3
0
 function test_update_metadata_by_mid()
 {
     // Setup
     $meta = get_metadata_by_mid('user', $this->meta_id);
     // Update the meta value
     $this->assertTrue(update_metadata_by_mid('user', $this->meta_id, 'meta_new_value'));
     $meta = get_metadata_by_mid('user', $this->meta_id);
     $this->assertEquals('meta_new_value', $meta->meta_value);
     // Update the meta value
     $this->assertTrue(update_metadata_by_mid('user', $this->meta_id, 'meta_new_value', 'meta_new_key'));
     $meta = get_metadata_by_mid('user', $this->meta_id);
     $this->assertEquals('meta_new_key', $meta->meta_key);
     // Update the key and value
     $this->assertTrue(update_metadata_by_mid('user', $this->meta_id, 'meta_value', 'meta_key'));
     $meta = get_metadata_by_mid('user', $this->meta_id);
     $this->assertEquals('meta_key', $meta->meta_key);
     $this->assertEquals('meta_value', $meta->meta_value);
     // Update the value that has to be serialized
     $this->assertTrue(update_metadata_by_mid('user', $this->meta_id, array('first', 'second')));
     $meta = get_metadata_by_mid('user', $this->meta_id);
     $this->assertEquals(array('first', 'second'), $meta->meta_value);
     // Let's try some invalid meta data
     $this->assertFalse(update_metadata_by_mid('user', 0, 'meta_value'));
     $this->assertFalse(update_metadata_by_mid('user', $this->meta_id, 'meta_value', array('invalid', 'key')));
     // Let's see if caches get cleared after updates.
     $meta = get_metadata_by_mid('user', $this->meta_id);
     $first = get_user_meta($meta->user_id, $meta->meta_key);
     $this->assertTrue(update_metadata_by_mid('user', $this->meta_id, 'other_meta_value'));
     $second = get_user_meta($meta->user_id, $meta->meta_key);
     $this->assertFalse($first === $second);
 }
 /**
  *	Process the request
  *	@todo Setting for reassigning user's posts
  */
 public function process()
 {
     // Verify the security nonce and die if it fails
     if (!isset($_POST['wp_delete_user_accounts_nonce']) || !wp_verify_nonce($_POST['wp_delete_user_accounts_nonce'], 'wp_delete_user_accounts_nonce')) {
         wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Request failed security check.', 'wp-delete-user-accounts')));
     }
     // Don't permit admins to delete their own accounts
     if (current_user_can('manage_options')) {
         wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Administrators cannot delete their own accounts.', 'wp-delete-user-accounts')));
     }
     // Get the current user
     $user_id = get_current_user_id();
     // Get user meta
     $meta = get_user_meta($user_id);
     // Delete user's meta
     foreach ($meta as $key => $val) {
         delete_user_meta($user_id, $key);
     }
     // Destroy user's session
     wp_logout();
     // Delete the user's account
     $deleted = wp_delete_user($user_id);
     if ($deleted) {
         // Send success message
         wp_send_json(array('status' => 'success', 'title' => __('Success!', 'wp-delete-user-accounts'), 'message' => __('Your account was successfully deleted. Fair well.', 'wp-delete-user-accounts')));
     } else {
         wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Request failed.', 'wp-delete-user-accounts')));
     }
 }
function ti_profile_fields($user)
{
    $is_approved = get_user_meta($user->ID, 'ti_is_approved', true);
    ?>

    <h3>Approve User to view products</h3>

    <table class="form-table">

        <tr>
            <th><label for="twitter">Approve as patient</label></th>

            <td>
                <select name="ti_is_approved">
                    <option value="">No</option>
                    <option <?php 
    echo $is_approved == 1 ? 'selected' : '';
    ?>
 value="1">Yes</option>
                </select>
            </td>
        </tr>

    </table>
    <?php 
}
 /**
  * Class constructor
  * 
  * Sets definitions
  * Adds methods to appropriate hooks
  * 
  * @author Ronald Huereca <*****@*****.**>
  * @since 1.0.0
  * @access public
  * @param array $args    If not set, then uses $defaults instead
  */
 public function __construct($args)
 {
     // Get posts per page
     $user_id = get_current_user_id();
     $posts_per_page = get_user_meta($user_id, 'reorder_items_per_page', true);
     if (!is_numeric($posts_per_page)) {
         $posts_per_page = 50;
     }
     $offset = absint($posts_per_page - 2);
     // Parse arguments
     $defaults = array('post_type' => '', 'posts_per_page' => $posts_per_page, 'offset' => $offset);
     $args = wp_parse_args($args, $defaults);
     // Set variables
     $this->post_type = $args['post_type'];
     //Get offset and posts_per_page
     $this->posts_per_page = absint($args['posts_per_page']);
     //todo - filterable?
     $this->offset = absint($args['offset']);
     //todo - filterable?
     if ($this->offset > $this->posts_per_page) {
         $this->offset = $this->posts_per_page;
     }
     //Add-on actions/filters
     add_action('metronet_reorder_menu_url_' . $this->post_type, array($this, 'set_reorder_url'));
     add_action('reorder_by_terms_interface_' . $this->post_type, array($this, 'output_interface'));
     add_action('metronet_reorder_posts_add_menu_' . $this->post_type, array($this, 'script_init'));
     add_filter('metronet_reorder_posts_tabs_' . $this->post_type, array($this, 'add_tab'));
     //Ajax actions
     add_action('wp_ajax_reorder_terms_only_sort', array($this, 'ajax_term_sort'));
 }
function rcl_ajax_delete_post()
{
    global $user_ID;
    if (!$user_ID) {
        return false;
    }
    $post = get_post(intval($_POST['post_id']));
    $res = wp_delete_post($post->ID);
    if ($res) {
        $temp_gal = get_user_meta($user_ID, 'tempgallery', 1);
        if ($temp_gal) {
            $cnt = count($temp_gal);
            foreach ((array) $temp_gal as $key => $gal) {
                if ($gal['ID'] == $_POST['post_id']) {
                    unset($temp_gal[$key]);
                }
            }
            foreach ((array) $temp_gal as $t) {
                $new_temp[] = $t;
            }
            if ($new_temp) {
                update_user_meta($user_ID, 'tempgallery', $new_temp);
            } else {
                delete_user_meta($user_ID, 'tempgallery');
            }
        }
        $log['result'] = 100;
        $log['post_type'] = $post->post_type;
    } else {
        $log['result'] = 1;
    }
    echo json_encode($log);
    exit;
}
 function WeddingGuest($id = null)
 {
     parent::__construct($id);
     $this->attending_wedding = (bool) get_user_meta($this->ID, '_attending_wedding', true);
     $this->attending_dinner = (bool) get_user_meta($this->ID, '_attending_dinner', true);
     $this->has_responded = (bool) ($this->_attending_wedding == '1' || $this->_attending_wedding == '0' || $this->_attending_dinner == '1' || $this->_attending_dinner == '0');
 }
function book_confirmed_responsable_template($user, $event, $email)
{
    $event_start_date = new DateTime(get_post_meta($event->ID, '_EventStartDate', true));
    $date = date_i18n("l d F Y", $event_start_date->getTimestamp());
    $user_meta = get_user_meta($user->ID);
    $full_name = $user_meta["first_name"][0] . " " . $user_meta["last_name"][0];
    ob_start();
    ?>

<p>
    Bonjour, merci d’avoir validé la participation au stage « Communication en situation d’urgence médiatique | Communication de crise » du <strong><?php 
    echo $date;
    ?>
</strong> de M/Mme <?php 
    echo $full_name;
    ?>
.
</p>

<p>
<?php 
    echo es_mail_sign();
    ?>
</p>

<?php 
    $mail = ob_get_contents();
    ob_clean();
    return $mail;
}
Example #10
0
 public function init(&$existing_meta_keys = array())
 {
     if (!self::$is_active) {
         return;
     }
     if (!empty(XmlExportEngine::$exportQuery->results)) {
         foreach (XmlExportEngine::$exportQuery->results as $user) {
             $record_meta = get_user_meta($user->ID, '');
             if (!empty($record_meta)) {
                 foreach ($record_meta as $record_meta_key => $record_meta_value) {
                     if (!in_array($record_meta_key, $existing_meta_keys)) {
                         $to_add = true;
                         foreach ($this->default_fields as $default_value) {
                             if ($record_meta_key == $default_value['name'] || $record_meta_key == $default_value['type']) {
                                 $to_add = false;
                                 break;
                             }
                         }
                         if ($to_add) {
                             foreach ($this->advanced_fields as $advanced_value) {
                                 if ($record_meta_key == $advanced_value['name'] || $record_meta_key == $advanced_value['type']) {
                                     $to_add = false;
                                     break;
                                 }
                             }
                         }
                         if ($to_add) {
                             $existing_meta_keys[] = $record_meta_key;
                         }
                     }
                 }
             }
         }
     }
 }
Example #11
0
 /**
  * Get a username value stored for the given WordPress user identifier
  *
  * @since 1.3.0
  *
  * @param int|string $user_id WordPress user identifier. may be WP_User->ID or a separate identifier used by an extending system
  * @param string     $key user attribute or meta key storing the username of interest
  *
  * @return string stored username. empty string if no user_id provided or no username found
  */
 public static function getSocialUsername($user_id, $key)
 {
     // basic test for invalid passed parameter
     if (!$user_id) {
         return '';
     }
     if (!is_string($key) || !$key) {
         return '';
     }
     if (function_exists('get_user_attribute')) {
         $username = get_user_attribute($user_id, $key);
     } else {
         $username = get_user_meta($user_id, $key, true);
     }
     if (!is_string($username)) {
         $username = '';
     }
     // pass a username through a filter if not explicitly defined through user meta
     if (!$username) {
         /**
          * Allow sites to provide a WordPress user's Twitter username through a filter
          *
          * @since 1.0.0
          *
          * @param string     $username Twitter username associated with a WordPress user ID
          * @param int|string $user_id  WordPress user identifier. may be WP_User->ID or a separate identifier used by an extending system
          */
         $username = apply_filters($key . '_username', $username, $user_id);
     }
     return $username;
 }
 /**
  * Output the message
  *
  * @since 0.1.0
  *
  * @param string $message The text of the message.
  * @param bool $error Optional. Whether to show as error or update. Default is error.
  * @param string $cap_check Optional. Minimum user capability to show nag to. Default is "activate_plugins"
  * @param string|bool $ignore_key Optional. The user meta key to use for storing if this message has been dismissed by current user or not. If false, it will be generated.
  *
  * @return string|void Admin notice if is_admin() and not dismissed.
  */
 public static function notice($message, $error = true, $cap_check = 'activate_plugins', $ignore_key = false)
 {
     if (is_admin() && (!defined('DOING_AJAX') || !DOING_AJAX)) {
         if (current_user_can($cap_check)) {
             $user_id = get_current_user_id();
             if (!is_string($ignore_key)) {
                 // cal_wd_ig_3911b2583433f696e5813a503bbb2e65
                 $ignore_key = 'cal_wd_ig_' . substr(md5($ignore_key), 0, 40);
             }
             self::$ignore_key = sanitize_key($ignore_key);
             $dissmised = get_user_meta($user_id, self::$ignore_key, true);
             if (!$dissmised) {
                 if ($error) {
                     $class = 'error';
                 } else {
                     $class = 'updated';
                 }
                 self::$nonce_field = wp_nonce_field(self::$nonce_action);
                 $out[] = sprintf('<div id="%1s" data-key="%2s" class="%3s notice is-dismissible"><p>', self::$ignore_key, self::$ignore_key, $class);
                 $out[] = $message;
                 $out[] = self::$nonce_field;
                 $out[] = '</p></div>';
                 add_action('admin_enqueue_scripts', array(__CLASS__, 'js_css'));
                 add_action('wp_ajax_caldera_warnings_dismissible_notice', array(__CLASS__, 'ajax_cb'));
                 return implode('', $out);
             }
         }
     }
 }
Example #13
0
/**
 * @param string $success_message - '', if present, will return an clickable link
 * @param string $error_message - "You don’t have access to this RSS feed."
 * @param bool $return
 * @return string
 */
function memberful_private_rss_feed_link($success_message = '', $error_message = "You don’t have access to this RSS feed.", $return = false)
{
    $error_message = apply_filters('memberful_private_rss_feed_error_message', $error_message);
    if (!is_user_logged_in()) {
        return memberful_private_rss_feed_link_response_helper($error_message, $return);
    }
    $requiredPlan = memberful_private_user_feed_settings_get_required_plan();
    // We want to allow the private user feed only if the admin has configured it.
    if ($requiredPlan == false) {
        return memberful_private_rss_feed_link_response_helper($error_message, $return);
    }
    $current_user_id = get_current_user_id();
    if (!is_subscribed_to_memberful_plan($requiredPlan, $current_user_id)) {
        return memberful_private_rss_feed_link_response_helper($error_message, $return);
    }
    $feedToken = get_user_meta($current_user_id, 'memberful_private_user_feed_token', true);
    if ($feedToken == false || $feedToken == '') {
        $feedToken = substr(md5(uniqid(rand(1, 10000))), 2, 30);
        update_user_meta($current_user_id, 'memberful_private_user_feed_token', $feedToken);
    }
    $link = get_home_url() . '/' . memberful_private_user_feed_get_url_identifier($feedToken);
    if ($success_message != '') {
        $link = '<a href="' . $link . '">' . do_shortcode($success_message) . '</a>';
    }
    return memberful_private_rss_feed_link_response_helper($link, $return);
}
Example #14
0
function userFistLastName($user_id){
    $firstname=get_user_meta($user_id, 'first_name', true);
    if($firstname == ""){
        update_user_meta($user_id, 'first_name', 'Jhony');
        update_user_meta($user_id, 'last_name', 'Waker');
    }
}
 public static function enqueue_scripts($hook_suffix)
 {
     self::$pointers = apply_filters('hackrepair_plugin_archiver_pointers', self::$pointers);
     // Check if screen related pointer is registered
     if (empty(self::$pointers[$hook_suffix])) {
         return;
     }
     $pointers = (array) self::$pointers[$hook_suffix];
     // Get dismissed pointers
     $dismissed = explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true));
     $got_pointers = false;
     foreach ($pointers as $key => $pointer) {
         if (in_array($key, $dismissed)) {
             continue;
         }
         if (isset($pointer['caps'])) {
             foreach ($pointer['caps'] as $cap) {
                 if (!current_user_can($cap)) {
                     continue 2;
                 }
             }
         }
         $callback = is_callable($pointer['callback']) ? $pointer['callback'] : array('HackRepair_Plugin_Archiver_Pointer', $pointer['callback']);
         add_action('admin_print_footer_scripts', $callback);
         $got_pointers = true;
     }
     if (!$got_pointers) {
         return;
     }
     // Add pointers script and style to queue
     wp_enqueue_style('wp-pointer');
     wp_enqueue_script('wp-pointer');
 }
 public static function multiple_roles($user_id, $roles = false)
 {
     global $wpdb, $wp_roles, $current_user, $pagenow;
     $roles = $roles ? $roles : (isset($_POST['roles']) && isset($_POST['roles'][0]) ? $_POST['roles'][0] : false);
     if ($roles && current_user_can('edit_user', $current_user->ID)) {
         $editable_roles = get_editable_roles();
         $user = new WP_User($user_id);
         $user_roles = array_intersect(array_values($user->roles), array_keys($editable_roles));
         $_user_role_log = get_user_meta($user_id, $wpdb->prefix . 'capabilities_log', true);
         $user_role_log = $_user_role_log ? $_user_role_log : array();
         $roles = is_array($roles) ? $roles : array($roles);
         foreach ($roles as $role) {
             if (!in_array($role, $user_roles) && $wp_roles->is_role($role)) {
                 $user->add_role($role);
                 array_push($user_role_log, array('action' => 'add', 'role' => $role, 'timestamp' => time()));
             }
         }
         foreach ($user_roles as $role) {
             if (!in_array($role, $roles) && $wp_roles->is_role($role)) {
                 $user->remove_role($role);
                 array_push($user_role_log, array('action' => 'remove', 'role' => $role, 'timestamp' => time()));
             }
         }
         update_user_meta($user_id, $wpdb->prefix . 'capabilities_log', $user_role_log);
     }
 }
Example #17
0
 function the_quiz_button($button, $quiz_id)
 {
     global $post;
     $quiz_id = get_the_ID();
     $user_id = get_current_user_id();
     $flag = 1;
     if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
         $pid = get_post_meta($quiz_id, 'vibe_quiz_product', true);
         if (isset($pid) && is_numeric($pid) && get_post_type($pid) == 'product') {
             $product_taken = wc_customer_bought_product('', $user_id, $pid);
             if (!$product_taken) {
                 $pid = get_permalink($pid);
                 $check = vibe_get_option('direct_checkout');
                 $check = intval($check);
                 if (isset($check) && $check) {
                     $pid .= '?redirect';
                 }
                 $flag = 0;
                 $html = '<a href="' . $pid . '"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '</a>';
             } else {
                 $flag = 1;
             }
         }
     }
     if (in_array('paid-memberships-pro/paid-memberships-pro.php', apply_filters('active_plugins', get_option('active_plugins'))) && is_user_logged_in()) {
         $membership_ids = vibe_sanitize(get_post_meta($quiz_id, 'vibe_quiz_membership', false));
         if (!pmpro_hasMembershipLevel($membership_ids, $user_id) && isset($membership_ids) && count($membership_ids) >= 1) {
             $membership_taken = get_user_meta($user_id, $quiz_id, true);
             if (!$membership_taken) {
                 $pmpro_levels_page_id = get_option('pmpro_levels_page_id');
                 $link = get_permalink($pmpro_levels_page_id);
                 $html = '<a href="' . $link . '"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '</a>';
                 $flag = 0;
             } else {
                 $flag = 1;
             }
         }
     }
     if (in_array('wplms-mycred-addon/wplms-mycred-addon.php', apply_filters('active_plugins', get_option('active_plugins')))) {
         $points = get_post_meta($quiz_id, 'vibe_quiz_mycred_points', true);
         $mycred = mycred();
         $balance = $mycred->get_users_cred($user_id);
         if ($balance < $points) {
             $flag = 0;
             $html = '<a href="#"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '<span>' . __('<br/>Not enough points.', 'vibe') . '</span></a>';
         }
         if (!$mycred->has_entry('purchase_quiz', $quiz_id, $user_id)) {
             $flag = 1;
             $deduct = -1 * $points;
             $mycred->update_users_balance($user_id, $deduct);
             $mycred->add_to_log('purchase_quiz', $user_id, $deduct, __('Student subscibed to quiz', 'wplms-mycred'), $quiz_id);
         } else {
             $flag = 1;
         }
     }
     if (!$flag) {
         return $html;
     }
     return $button;
 }
Example #18
0
 function _admin_init()
 {
     global $post;
     $screen = get_current_screen();
     $pointers = array();
     if ($screen->base == 'post' && $screen->post_type == UBERGRID_POST_TYPE) {
         $pointers = array('#add-new-cell' => array('title' => __('Add a cell', 'uber-grid'), 'content' => __('<p>Click here to add a first cell to your grid.</p>', 'uber-grid'), 'position' => array('edge' => 'right', 'align' => 'center')), '#shortcode' => array('title' => __('Save your grid', 'uber-grid'), 'content' => sprintf(__('<p>After saving your grid, insert this code <strong>[ubergrid id=%s]</strong> into your site pages to use the grid.</p>', 'uber-grid'), $post->ID), 'position' => array('edge' => 'top')));
     }
     if ($screen->base == 'edit' && $screen->post_type == UBERGRID_POST_TYPE) {
         $pointers = array('.add-new-h2' => array('title' => __('Create a grid', 'uber-grid'), 'content' => __('<p>Please click here to create your first grid.</p>', 'uber-grid')));
     }
     $disabled = get_user_meta(get_current_user_id(), 'uber_grid_disabled_pointers', true);
     if ($disabled) {
         foreach ($disabled as $item) {
             if (isset($pointers[$item])) {
                 unset($pointers[$item]);
             }
         }
     }
     if ($pointers) {
         wp_enqueue_script("wp-pointer");
         wp_enqueue_style("wp-pointer");
         wp_enqueue_script('uber-grid-pointers', UBERGRID_URL . 'assets/js/admin-pointers.js');
         wp_localize_script('uber-grid-pointers', 'uber_grid_pointers', array($pointers));
     }
 }
Example #19
0
function mb_get_user_topic_bookmarks($user_id)
{
    $user_id = mb_get_user_id($user_id);
    $bookmarks = get_user_meta($user_id, mb_get_user_topic_bookmarks_meta_key(), true);
    $bookmarks = !empty($bookmarks) ? explode(',', $bookmarks) : array();
    return apply_filters('mb_get_user_topic_bookmarks', $bookmarks, $user_id);
}
    public function user_checkbox($user)
    {
        global $edd_options;
        $unlimited = get_user_meta($user->ID, '_edd_recurring_unlimited', true);
        ?>
		<table class="form-table">
			<tbody>
				<tr>
					<th>
						<label for="edd_recurring_unlimited"><?php 
        _e('Unlimited Recurring Access', 'edd');
        ?>
</label>
					</th>
					<td>
						<input name="edd_recurring_unlimited" type="checkbox" id="edd_recurring_unlimited" value="0"<?php 
        checked(true, $unlimited);
        ?>
/>
						<span class="description"><?php 
        _e('Grant user unlimited access for recurring downloads. Checking this means a user will not need a subscription to download files.', 'edd');
        ?>
</span>
					</td>
				</tr>
			</tbody>
		</table>
		<?php 
    }
 /**
  * Set extra user fields
  */
 private function set_user_meta()
 {
     $user_meta = get_user_meta($this->input['ID']);
     if (!empty($user_meta)) {
         $this->user_meta = $user_meta;
     }
 }
Example #22
0
 /**
  * Creates the pending referral during signup
  *
  * @access  public
  * @since   1.0
  */
 public function add_pending_referral($post_data, $user_id, $price)
 {
     $affiliate_discount = false;
     if (!empty($_POST['rcp_discount'])) {
         global $wpdb;
         $rcp_discounts = new RCP_Discounts();
         $discount_obj = $rcp_discounts->get_by('code', $_POST['rcp_discount']);
         $affiliate_id = $wpdb->get_var($wpdb->prepare("SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = %s", 'affwp_discount_rcp_' . $discount_obj->id));
         $user_id = affwp_get_affiliate_user_id($affiliate_id);
         $discount_aff = get_user_meta($user_id, 'affwp_discount_rcp_' . $discount_obj->id, true);
         if ($discount_aff && affiliate_wp()->tracking->is_valid_affiliate($affiliate_id)) {
             $affiliate_discount = true;
             $this->affiliate_id = $affiliate_id;
             $key = rcp_get_subscription_key($user_id);
             $amount = $this->calculate_referral_amount($price, $key, absint($_POST['rcp_level']));
             if (0 == $amount && affiliate_wp()->settings->get('ignore_zero_referrals')) {
                 return false;
                 // Ignore a zero amount referral
             }
             $referral_id = affiliate_wp()->referrals->add(array('amount' => $amount, 'reference' => rcp_get_subscription_key($user_id), 'description' => rcp_get_subscription($user_id), 'affiliate_id' => $this->affiliate_id, 'context' => $this->context, 'campaign' => affiliate_wp()->tracking->get_campaign()));
         }
     }
     if ($this->was_referred() && !$affiliate_discount) {
         $user = get_userdata($user_id);
         if ($this->is_affiliate_email($user->user_email)) {
             return;
             // Customers cannot refer themselves
         }
         $key = rcp_get_subscription_key($user_id);
         $total = $this->calculate_referral_amount($price, $key, absint($_POST['rcp_level']));
         $this->insert_pending_referral($total, $key, rcp_get_subscription($user_id));
     }
 }
Example #23
0
 private static function get_avatar_from_meta($url, $user_id)
 {
     static $caches = [];
     if (isset($caches[$user_id])) {
         return $caches[$user_id];
     }
     $meta = get_user_meta($user_id, self::$user_meta_key['avatar'], true);
     if (empty($meta)) {
         $caches[$user_id] = $url;
         return $caches[$user_id];
     }
     /**
      * if is /12/2015/xx.jpg format, add upload baseurl
      */
     if (strpos($meta, 'http') === false || strpos($meta, '//') === false) {
         static $baseurl;
         if (!$baseurl) {
             $baseurl = wp_upload_dir()['baseurl'];
         }
         $caches[$user_id] = $baseurl . $meta;
     } else {
         $caches[$user_id] = $meta;
     }
     return $caches[$user_id];
 }
 /**
  * Output the message
  *
  * @since 0.1.0
  *
  * @param string $message The text of the message.
  * @param bool $error Optional. Whether to show as error or update. Default is error.
  * @param string $cap_check Optional. Minimum user capability to show nag to. Default is "activate_plugins"
  * @param string|bool $ignore_key Optional. The user meta key to use for storing if this message has been dismissed by current user or not. If false, it will be generated.
  *
  * @return string|void Admin notice if is_admin() and not dismissed.
  */
 public static function notice($message, $error = true, $cap_check = 'activate_plugins', $ignore_key = false)
 {
     if (!current_user_can($cap_check)) {
         return;
     }
     $user_id = get_current_user_id();
     if (!is_string($ignore_key)) {
         // cal_wd_ig_3911b2583433f696e5813a503bbb2e65
         $ignore_key = 'cal_wd_ig_' . substr(md5($ignore_key), 0, 40);
     }
     self::$ignore_key = sanitize_key($ignore_key);
     $dissmised = time() - get_user_meta($user_id, self::$ignore_key, time()) < 60 * 60 * 24 * 30;
     // Nag every 30 days
     if ($dissmised) {
         return;
     }
     if ($error) {
         $class = 'error';
     } else {
         $class = 'update-nag';
     }
     self::$nonce_field = wp_nonce_field(self::$nonce_action);
     $out[] = sprintf('<div id="%1s" data-key="%2s" class="%3s notice is-dismissible">', self::$ignore_key, self::$ignore_key, $class);
     $out[] = $message;
     $out[] = self::$nonce_field;
     $out[] = '</div>';
     return implode('', $out);
 }
 public function add_pointers()
 {
     $pointers = $this->pointers;
     if (!$pointers || !is_array($pointers)) {
         return;
     }
     // Get dismissed pointers
     $dismissed = explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true));
     $valid_pointers = array();
     // Check pointers and remove dismissed ones.
     foreach ($pointers as $pointer_id => $pointer) {
         // Make sure we have pointers & check if they have been dismissed
         if (in_array($pointer_id, $dismissed) || empty($pointer) || empty($pointer_id) || empty($pointer['target']) || empty($pointer['options'])) {
             continue;
         }
         $pointer['pointer_id'] = $pointer_id;
         // Add the pointer to $valid_pointers array
         $valid_pointers['pointers'][] = $pointer;
     }
     // No valid pointers? Stop here.
     if (empty($valid_pointers)) {
         return;
     }
     $this->valid = $valid_pointers;
     wp_enqueue_style('wp-pointer');
     wp_enqueue_script('wp-pointer');
 }
Example #26
0
    /**
     * Outputs the content of the widget
     *
     * @param array $args
     * @param array $instance
     */
    public function widget($args, $instance) {

        $title = apply_filters('widget_title', $instance['title']);

        echo $args['before_widget'];
        echo '<div class="event-widget">';

        if (is_user_logged_in()) {
            if (!empty($instance['title'])) {
                echo $args['before_title'] . __('Profile Links') . $args['after_title'];
            }
            $user_ID = get_current_user_id();
            $profile_id = get_user_meta($user_ID, 'uiu_profile', TRUE);
            $profile_link = !empty($profile_id) ? get_permalink($profile_id) : get_dashboard_url($user_ID);
            ?>
            <ul class="menu user-menu">
                <li class="menu-item"><a href="<?php echo $profile_link; ?>">My Profile</a>  </li>               
                <li class="menu-item"><a href="<?php echo wp_logout_url(site_url()); ?>">Logout</a>  </li>

            </ul>
            <?php
        } else {
            if (!empty($instance['title'])) {
                echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
            }
            wp_login_form($args);
        }
        echo $args['after_widget'];
    }
    public function addOperatorNameField($user)
    {
        if (!user_can($user, 'chamame_chat_with_visitor')) {
            return;
        }
        $name = esc_attr(get_user_meta($user->ID, 'chamameOperatorName', true));
        $textDomain = $this->config->getTextDomain();
        $header = esc_html(__('Chat Settings', $textDomain));
        $label = esc_html(__('Operator Name', $textDomain));
        $description = esc_html(__('Input operator name. If this item is empty, "Display name publicly as" is displayed as operator name.', $textDomain));
        echo <<<EOM
<h3>{$header}</h3>
<table class="form-table">
  <tr>
    <th scope="row">
      <label for="chamameOperatorName">{$label}</label>
    </th>
    <td>
      <input type="text" id="chamameOperatorName" name="chamameOperatorName" value="{$name}" class="regular-text" />
      <br />
      <span class="description">{$description}</span>
    </td>
  </tr>
</table>
EOM;
    }
Example #28
0
function fa_avatar_hook($avatar, $id_or_email, $size, $default, $alt)
{
    $user = false;
    if (is_numeric($id_or_email)) {
        $id = (int) $id_or_email;
        $user = get_user_by('id', $id);
    } elseif (is_object($id_or_email)) {
        if (!empty($id_or_email->user_id)) {
            $id = (int) $id_or_email->user_id;
            $user = get_user_by('id', $id);
        }
    } else {
        $user = get_user_by('email', $id_or_email);
    }
    if ($user && is_object($user)) {
        if (get_user_meta($user->data->ID, 'weixin_avatar', true)) {
            $avatar = get_user_meta($user->data->ID, 'weixin_avatar', true);
            $avatar = str_replace('http', 'https', $avatar);
            $avatar = "<img alt='{$alt}' src='{$avatar}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
        } else {
            if (get_user_meta($user->data->ID, 'sina_avatar', true)) {
                $avatar = get_user_meta($user->data->ID, 'sina_avatar', true);
                $avatar = "<img alt='{$alt}' src='{$avatar}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
            }
        }
        //根据你的存储头像的key来写
    }
    return $avatar;
}
 /**
  * return user balance formated as dollars
  * @return [type] [description]
  */
 function get_user_balance()
 {
     $current_user_balance = get_user_meta($_POST['user_id'], '_uw_balance', true);
     $return = array('status' => true, 'balance' => wc_price($current_user_balance));
     print json_encode($return);
     exit;
 }
 public function check_img_size($file)
 {
     $mis_params = get_option('mis_img_params');
     // Check to see what kind of input the user is editing
     $meta_key = get_user_meta(get_current_user_id(), 'last_user_field_mod', true);
     // check if there is a custom field image restriction
     if (is_array($mis_params['custom_field']) && array_key_exists($meta_key['field_key'], $mis_params['custom_field'])) {
         $min_width = $mis_params['custom_field'][$meta_key['field_key']][0];
         $min_height = $mis_params['custom_field'][$meta_key['field_key']][1];
     } elseif ($meta_key['field_key'] === false) {
         $post_type = get_post_type($_REQUEST['post_id']);
         if (is_array($mis_params['post_type']) && array_key_exists($post_type, $mis_params['post_type'])) {
             $min_width = $mis_params['post_type'][$post_type][0];
             $min_height = $mis_params['post_type'][$post_type][1];
         }
     }
     if (isset($min_width) && isset($min_height)) {
         $img = getimagesize($file['tmp_name']);
         $minimum = array('width' => $min_width, 'height' => $min_height);
         $width = $img[0];
         $height = $img[1];
         if ($width < $minimum['width']) {
             return array("error" => "Image dimensions are too small. Minimum width is {$minimum['width']}px. Uploaded image width is {$width} px");
         } elseif ($height < $minimum['height']) {
             return array("error" => "Image dimensions are too small. Minimum height is {$minimum['height']}px. Uploaded image height is {$height} px");
         } else {
             return $file;
         }
     } else {
         return $file;
     }
 }