当前位置: 首页>>代码示例>>PHP>>正文


PHP get_userdata函数代码示例

本文整理汇总了PHP中get_userdata函数的典型用法代码示例。如果您正苦于以下问题:PHP get_userdata函数的具体用法?PHP get_userdata怎么用?PHP get_userdata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_userdata函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: notification_email

 /**
  * Set the notification email when sending an email.
  *
  * @since WP Job Manager - Contact Listing 1.0.0
  *
  * @return string The email to notify.
  */
 public function notification_email($components, $cf7, $three = null)
 {
     $submission = WPCF7_Submission::get_instance();
     $unit_tag = $submission->get_meta('unit_tag');
     if (!preg_match('/^wpcf7-f(\\d+)-p(\\d+)-o(\\d+)$/', $unit_tag, $matches)) {
         return $components;
     }
     $post_id = (int) $matches[2];
     $object = get_post($post_id);
     // Prevent issues when the form is not submitted via a listing/resume page
     if (!isset($this->forms[$object->post_type])) {
         return $components;
     }
     if (!array_search($cf7->id(), $this->forms[$object->post_type])) {
         return $components;
     }
     // Bail if this is the second mail
     if (isset($three) && 'mail_2' == $three->name()) {
         return $components;
     }
     $recipient = $object->_application ? $object->_application : $object->_candidate_email;
     //if we couldn't find the email by now, get it from the listing owner/author
     if (empty($recipient)) {
         //just get the email of the listing author
         $owner_ID = $object->post_author;
         //retrieve the owner user data to get the email
         $owner_info = get_userdata($owner_ID);
         if (false !== $owner_info) {
             $recipient = $owner_info->user_email;
         }
     }
     $components['recipient'] = $recipient;
     return $components;
 }
开发者ID:durichitayat,项目名称:befolio-wp,代码行数:41,代码来源:cf7.php

示例2: get_permalink

 function get_permalink($id = false)
 {
     $rewritecode = array('%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', '%postname%', '%post_id%', '%category%', '%author%', '%pagename%');
     $permalink = get_settings('permalink_structure');
     $postHandler =& wp_handler('Post');
     if ($id) {
         $id = intval($id);
         if ($permalink == '') {
             return wp_siteurl() . '/index.php?p=' . $id;
         }
         if (!isset($GLOBALS['permalink_cache'][wp_id()]) || !isset($GLOBALS['permalink_cache'][wp_id()][$id])) {
             $postObject =& $postHandler->get($id);
             $GLOBALS['permalink_cache'][wp_id()][$id] =& $postObject->exportWpObject();
         }
         $idpost = $GLOBALS['permalink_cache'][wp_id()][$id];
     } else {
         $idpost = $GLOBALS['post'];
     }
     if ('' != $permalink) {
         $unixtime = strtotime($idpost->post_date);
         $cats = get_the_category($idpost->ID);
         $category = $cats[0]->category_nicename;
         $authordata = get_userdata($idpost->post_author);
         $author = $authordata->user_login;
         $rewritereplace = array(date('Y', $unixtime), date('m', $unixtime), date('d', $unixtime), date('H', $unixtime), date('i', $unixtime), date('s', $unixtime), $idpost->post_name, $idpost->ID, $category, $author, $idpost->post_name);
         return wp_siteurl() . str_replace($rewritecode, $rewritereplace, $permalink);
     } else {
         return wp_siteurl() . '/index.php?p=' . $idpost->ID;
     }
 }
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:30,代码来源:template-functions-links.php

示例3: glossary_entries_get

 public function glossary_entries_get($project_path, $locale_slug, $translation_set_slug)
 {
     $project = GP::$project->by_path($project_path);
     $locale = GP_Locales::by_slug($locale_slug);
     if (!$project || !$locale) {
         return $this->die_with_404();
     }
     $translation_set = GP::$translation_set->by_project_id_slug_and_locale($project->id, $translation_set_slug, $locale_slug);
     if (!$translation_set) {
         return $this->die_with_404();
     }
     $glossary = GP::$glossary->by_set_or_parent_project($translation_set, $project);
     if (!$glossary) {
         return $this->die_with_404();
     }
     $glossary_entries = GP::$glossary_entry->by_glossary_id($glossary->id);
     foreach ($glossary_entries as $key => $entry) {
         $user = get_userdata($entry->last_edited_by);
         if ($user) {
             $glossary_entries[$key]->user_login = $user->user_login;
             $glossary_entries[$key]->user_display_name = $user->display_name;
         }
     }
     $can_edit = $this->can('approve', 'translation-set', $translation_set->id);
     $url = gp_url_join(gp_url_project_locale($project_path, $locale_slug, $translation_set_slug), array('glossary'));
     $this->tmpl('glossary-view', get_defined_vars());
 }
开发者ID:akirk,项目名称:GlotPress,代码行数:27,代码来源:glossary-entry.php

示例4: user_menu

 /**
  * 
  *  Woo User Menu
  */
 function user_menu()
 {
     $_Twoot_Woo = new Twoot_Woo();
     $url = $_Twoot_Woo->shop_urls();
     $user_data = get_userdata(get_current_user_id());
     $avatar = get_option('show_avatars') ? '<span class="avatar">' . get_avatar(get_current_user_id(), 20) . '</span>' : '';
     $tag = get_option('permalink_structure') == false ? '&' : '?';
     $html = '<nav id="woo-user-menu">';
     $html .= '<ul class="sf-menu clearfix">';
     if (is_user_logged_in()) {
         $html .= '<li class="my-account"><a href="' . $url['account_overview'] . '">' . $avatar . esc_attr__('Howdy, ', 'Twoot') . $user_data->display_name . '</a>';
         $html .= '<ul>';
         $html .= '<li class="account-change-pw"><a href="' . $url['account_change_pw'] . '">' . esc_attr__('Change Password', 'Twoot') . '</a></li>';
         $html .= '<li class="account-edit-adress"><a href="' . $url['account_edit_adress'] . '">' . esc_attr__('Edit Address', 'Twoot') . '</a></li>';
         $html .= '<li class="account-view-order"><a href="' . $url['account_view_order'] . '">' . esc_attr__('View Order', 'Twoot') . '</a></li>';
         $html .= '<li class="cart"><a href="' . $url['cart'] . '">' . esc_attr__('Shopping Cart', 'Twoot') . '</a></li>';
         $html .= '<li class="checkout"><a href="' . $url['checkout'] . '">' . esc_attr__('Checkout', 'Twoot') . '</a></li>';
         $html .= '</ul>';
         $html .= '</li>';
         $html .= '<li class="logout last"><a href="' . $url['logout'] . '">' . esc_attr__('Sign Out', 'Twoot') . '</a></li>';
     } else {
         if (get_option('users_can_register') && get_option('woocommerce_enable_myaccount_registration') == 'yes') {
             $html .= '<li class="register"><a href="' . $url['register'] . $tag . 'user_account=register">' . esc_attr__('Create Account', 'Twoot') . '</a></li>';
         }
         $html .= '<li class="login last"><a href="' . $url['account_overview'] . $tag . 'user_account=login">' . esc_attr__('Sign In', 'Twoot') . '</a></li>';
     }
     $html .= '</ul>';
     $html .= '</nav>';
     return $html;
 }
开发者ID:sniezekjp,项目名称:prod-fs,代码行数:34,代码来源:woo-generator.php

示例5: is_coauthor_for_post

/**
 * Checks to see if the the specified user is author of the current global post or post (if specified)
 * @param object|int $user
 * @param int $post_id
 */
function is_coauthor_for_post($user, $post_id = 0)
{
    global $post;
    if (!$post_id && $post) {
        $post_id = $post->ID;
    }
    if (!$post_id) {
        return false;
    }
    if (!$user) {
        return false;
    }
    $coauthors = get_coauthors($post_id);
    if (is_numeric($user)) {
        $user = get_userdata($user);
        $user = $user->user_login;
    } else {
        if (isset($user->user_login)) {
            $user = $user->user_login;
        } else {
            return false;
        }
    }
    foreach ($coauthors as $coauthor) {
        if ($user == $coauthor->user_login || $user == $coauthor->linked_account) {
            return true;
        }
    }
    return false;
}
开发者ID:hbarroso,项目名称:Co-Authors-Plus,代码行数:35,代码来源:template-tags.php

示例6: rssmi_show_custom_columns

/**
 * Display custom columns for RSS Feeds
 *
 * @param $column
 * @param $post_id
 */
function rssmi_show_custom_columns($column, $post_id)
{
    global $wpdb;
    switch ($column) {
        case 'url':
            $url = get_post_meta($post_id, 'rssmi_url', true);
            echo '<a href="' . esc_url($url) . '">' . esc_url($url) . '</a>';
            break;
        case 'category':
            $category = get_post_meta($post_id, 'rssmi_cat', true);
            echo esc_html(wp_getCategoryName($category));
            break;
        case 'bloguser':
            $bloguser = get_post_meta($post_id, 'rssmi_user', true);
            $bloguser = (int) $bloguser;
            echo esc_html(get_userdata($bloguser)->display_name);
            break;
        case 'feeditems':
            $post_count = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM (SELECT * from {$wpdb->postmeta} as a inner join {$wpdb->posts} as b on b.id=a.post_id where meta_key='rssmi_item_feed_id' and meta_value=%d order by post_id desc LIMIT 25) as c order by post_id ASC", $post_id));
            echo $post_count;
            break;
        case 'lastupdate':
            if (get_post_meta($post_id, 'rssmi_last_update', true) != '') {
                $last_update = get_post_meta($post_id, 'rssmi_last_update', true);
                echo get_date_from_gmt(date('Y-m-d H:i:s', $last_update), 'M j, Y @ g:i a  ');
            } else {
                echo "No Recent Update Yet";
            }
            break;
        case 'ID':
            echo $post_id;
            break;
    }
}
开发者ID:scottnkerr,项目名称:eeco,代码行数:40,代码来源:custom_posts.php

示例7: column_default

    function column_default($item, $column_name)
    {
        switch ($column_name) {
            case 'author':
                $user_info = get_userdata($item->post_author);
                if (!$user_info) {
                    echo '<strong>Anonymous</strong>';
                } else {
                    echo '<strong>' . get_avatar($item->post_author, $size = '32') . ' ' . $user_info->display_name . '</strong>';
                }
                break;
            case 'detail':
                global $post;
                setup_postdata($item);
                ?>
        		<div class="submitted-on"><?php 
                _e('Answered on ', 'dwqa');
                ?>
<a href="<?php 
                echo get_permalink($item->ID);
                ?>
"><?php 
                echo $item->post_date;
                ?>
</a></div>
        		<?php 
                the_excerpt();
                ?>
        		<?php 
                break;
            default:
                return print_r($item, true);
        }
    }
开发者ID:christianlee13,项目名称:dw-question-answer,代码行数:34,代码来源:class-answers-list-table.php

示例8: add_new_bookmark

function add_new_bookmark()
{
    if (!current_user_can('publish_posts')) {
        wp_redirect(get_bloginfo('url'));
        exit;
    }
    check_admin_referer('new-post');
    $user = get_userdata($current_user->ID);
    $post_title = urldecode($_POST['posttitle']);
    $post_url = urldecode($_POST['posturl']);
    $post_content = urldecode($_POST['posttext']);
    $tags = urldecode($_POST['tags']);
    $status = urldecode($_POST['status']);
    global $wpdb;
    // Search existing post with this pressmark-url
    $existing_post_id = $wpdb->get_var("SELECT post_id FROM {$wpdb->postmeta} \n\t\t\t\t\t\t\t\t\tWHERE meta_key = 'pressmark-url' AND meta_value = '{$post_url}'");
    if ($existing_post_id) {
        // If exists, add coauthor
        add_post_meta($existing_post_id, 'coauthor', (int) $user->ID, false);
        // Place post on top
        $post_modified = current_time('mysql');
        $post_modified_gmt = current_time('mysql', 1);
        $wpdb->query("UPDATE {$wpdb->posts} \n\t\t\t\t\tSET post_date = {$post_modified} \n\t\t\t\t\tSET post_date_gmt = {$post_modified_gmt}\n\t\t\t\t\tWHERE ID = '{$existing_post_id}'");
    } else {
        // If not exists, insert new post
        $post_id = wp_insert_post(array('post_author' => $user->ID, 'post_title' => $post_title, 'post_content' => $post_content, 'tags_input' => $tags, 'post_status' => $status));
        $wpdb->query("\n\t\t\t\tINSERT INTO {$wpdb->postmeta}\n\t\t\t\t(post_id,meta_key,meta_value )\n\t\t\t\tVALUES ('{$post_id}','pressmark-url','{$post_url}' )\n\t\t\t");
    }
}
开发者ID:alx,项目名称:pressmark,代码行数:29,代码来源:functions.php

示例9: run_checks

 /**
  * Runs checks for necessary config options.
  *
  * @return void Method does not return.
  */
 public function run_checks()
 {
     $role = get_role('administrator');
     $current_user = get_userdata(get_current_user_id());
     if (!is_object($role) || !is_object($current_user) || !$role->has_cap('manage_ai1ec_options') || defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     global $plugin_page;
     $settings = $this->_registry->get('model.settings');
     $notification = $this->_registry->get('notification.admin');
     $notifications = array();
     // check if is set calendar page
     if (!$settings->get('calendar_page_id')) {
         $msg = Ai1ec_I18n::__('Select an option in the <strong>Calendar page</strong> dropdown list.');
         $notifications[] = $msg;
     }
     if ($plugin_page !== AI1EC_PLUGIN_NAME . '-settings' && !empty($notifications)) {
         if ($current_user->has_cap('manage_ai1ec_options')) {
             $msg = sprintf(Ai1ec_I18n::__('The plugin is installed, but has not been configured. <a href="%s">Click here to set it up now &raquo;</a>'), admin_url(AI1EC_SETTINGS_BASE_URL));
             $notification->store($msg, 'updated', 2, array(Ai1ec_Notification_Admin::RCPT_ADMIN));
         } else {
             $msg = Ai1ec_I18n::__('The plugin is installed, but has not been configured. Please log in as an Administrator to set it up.');
             $notification->store($msg, 'updated', 2, array(Ai1ec_Notification_Admin::RCPT_ALL));
         }
         return;
     }
     foreach ($notifications as $msg) {
         $notification->store($msg, 'updated', 2, array(Ai1ec_Notification_Admin::RCPT_ADMIN));
     }
 }
开发者ID:newmight2015,项目名称:psmpsm,代码行数:35,代码来源:check.php

示例10: tdomf_get_admin_emails

function tdomf_get_admin_emails($form_id)
{
    global $wpdb;
    // grab email addresses
    $email_list = "";
    $notify_roles = tdomf_get_option_form(TDOMF_NOTIFY_ROLES, $form_id);
    if ($notify_roles != false) {
        if ($notify_roles != false) {
            $users = tdomf_get_all_users();
            $notify_roles = explode(';', $notify_roles);
            foreach ($users as $user) {
                $user = get_userdata($user->ID);
                if (!empty($user->user_email)) {
                    foreach ($notify_roles as $role) {
                        if (!empty($role) && isset($user->{$wpdb->prefix . 'capabilities'}[$role])) {
                            $email_list .= $user->user_email . ", ";
                            break;
                        }
                    }
                }
            }
        }
    }
    $more_emails = tdomf_get_option_form(TDOMF_OPTION_ADMIN_EMAILS, $form_id);
    if ($more_emails) {
        $email_list .= $more_emails;
    }
    return $email_list;
}
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:29,代码来源:tdomf-notify.php

示例11: getWeekBlog

function getWeekBlog()
{
    global $wpdb;
    $counter = 0;
    $posts = array();
    $blog = $wpdb->get_col("SELECT blogName FROM wp_weekblog WHERE endPublish >= CURRENT_DATE() AND initPublish <= CURRENT_DATE() AND active=1 ORDER BY endPublish limit 0,1");
    $blogd = $wpdb->get_col("SELECT description FROM wp_weekblog WHERE endPublish >= CURRENT_DATE() AND initPublish <= CURRENT_DATE() AND active=1 ORDER BY endPublish limit 0,1");
    if ($blog[0] == '') {
        return $posts;
    }
    if (!file_exists(bloginfo('template_directory') . '/images/weekblog/' . $blog[0] . '.png')) {
        return $posts;
    }
    $blogId = $wpdb->get_results("SELECT blog_id,domain,path from {$wpdb->blogs} WHERE path like '" . PATH_CURRENT_SITE . "{$blog['0']}/'");
    $blogOptionsTable = "wp_" . $blogId[0]->blog_id . "_options";
    $blogPostsTable = "wp_" . $blogId[0]->blog_id . "_posts";
    $options = $wpdb->get_results("SELECT option_value FROM {$blogOptionsTable} WHERE option_name IN ('siteurl','blogname') ORDER BY option_id, option_name DESC");
    $thispost = $wpdb->get_results("SELECT post_title, guid, post_content, post_date, post_author " . "FROM {$blogPostsTable} " . "WHERE post_status = 'publish' " . "AND post_title<>'' " . "AND post_type = 'post' " . "ORDER BY {$blogPostsTable}.id DESC limit 0,3");
    $thisusername = get_userdata($thispost[0]->post_author)->user_login;
    if ($thispost[1]->post_title == '') {
        return $posts;
    }
    $posts = array('title0' => $thispost[0]->post_title, 'title1' => $thispost[1]->post_title, 'guid0' => $thispost[0]->guid, 'guid1' => $thispost[1]->guid, 'blogTitle' => $options[1]->option_value, 'blogUrl' => $options[0]->option_value, 'imgName' => $blog[0], 'description' => $blogd[0]);
    return $posts;
}
开发者ID:ignacioabejaro,项目名称:xtecblocs,代码行数:25,代码来源:xtecfunc.php

示例12: add_required_data

/**
 * If the user leaves certain meta info blank, forcefully fill it with our own
 *
 * @param int $pid
 * @param \WP_Post $post
 */
function add_required_data($pid, $post)
{
    $pb_author = get_post_meta($pid, 'pb_author', true);
    if (!$pb_author) {
        // if the pb_author metadata value is not set, set it to the primary book user's name
        if (0 !== get_current_user_id()) {
            /** @var $user_info \WP_User */
            $user_info = get_userdata(get_current_user_id());
            $name = $user_info->display_name;
            update_post_meta($pid, 'pb_author', $name);
        }
    }
    $pb_language = get_post_meta($pid, 'pb_language', true);
    if (!$pb_language) {
        // if the pb_language metadata value is not set, set it to the network default
        $locale = get_site_option('WPLANG');
        $locale = array_search($locale, \PressBooks\L10n\wplang_codes());
        if (!$locale) {
            $locale = 'en';
        }
        update_post_meta($pid, 'pb_language', $locale);
    }
    $pb_cover_image = get_post_meta($pid, 'pb_cover_image', true);
    if (!$pb_cover_image) {
        // if the pb_cover_image metadata value is not set, set it to the default image
        update_post_meta($pid, 'pb_cover_image', \PressBooks\Image\default_cover_url());
    }
}
开发者ID:cumi,项目名称:pressbooks,代码行数:34,代码来源:pb-metaboxes.php

示例13: load_member_page

function load_member_page()
{
    $id = $_POST['id'];
    $current_member = get_userdata($id);
    include locate_template('template-part-member.php');
    die;
}
开发者ID:synergia,项目名称:mknm-synergia-theme,代码行数:7,代码来源:ajax.php

示例14: userstats

 public function userstats($atts)
 {
     if (!is_user_logged_in()) {
         return;
     }
     extract($this->correct(wp_parse_args($atts, $this->stataway_user), $this->shortcodes['stataway_user']));
     global $wpdb;
     $userid = $user && is_numeric($user) ? $user : get_current_user_id();
     if (!get_userdata($userid)) {
         return false;
     }
     fileaway_utility::timezone();
     $now = date('Y-m-d H:i:s');
     switch ($scope) {
         case '24hrs':
             $begin = date('Y-m-d H:i:s', strtotime($now . ' - 24 hours'));
             break;
         case 'week':
             $begin = date('Y-m-d H:i:s', strtotime($now . ' - 1 week'));
             break;
         case 'twoweeks':
             $begin = date('Y-m-d H:i:s', strtotime($now . ' - 2 weeks'));
             break;
         case 'month':
             $begin = date('Y-m-d H:i:s', strtotime($now . ' - 30 days'));
             break;
         case 'year':
             $begin = date('Y-m-d H:i:s', strtotime($now . ' - 1 year'));
             break;
         case 'all':
             $begin = '1900-01-01 00:00:00';
             break;
         default:
             $begin = date('Y-m-d H:i:s', strtotime($now . ' - 1 week'));
     }
     $end = $now;
     $records = $wpdb->get_results($wpdb->prepare("SELECT file, timestamp FROM " . fileaway_stats::$db . " WHERE uid = %d AND timestamp >= %s AND timestamp <= %s ORDER BY timestamp DESC", $userid, $begin, $end), ARRAY_A);
     if (!$records || count($records) < 1) {
         $count = 0;
     } else {
         $count = count($records);
     }
     date_default_timezone_set('UTC');
     if ($output == 'total') {
         return '<span class="' . $class . '">' . $count . '</span>';
     }
     if ($count < 1) {
         return false;
     }
     $datestring = $this->op['daymonth'] == 'md' ? 'm/d/Y' : 'd/m/Y';
     $items = array();
     foreach ($records as $i => $record) {
         $items[$i] = '<li>' . fileaway_utility::basename($record['file']);
         if ($timestamp == 'yes') {
             $items[$i] .= ' <span style="display:block;" class="' . $class . 'timestamp">' . date($datestring . ' ' . get_option('time_format'), strtotime($record['timestamp'])) . '</span>';
         }
         $items[$i] .= '</li>';
     }
     return '<div class="' . $class . '"><' . $output . '>' . implode($items) . '</' . $output . '></div>';
 }
开发者ID:Nguyenkain,项目名称:strida.vn,代码行数:60,代码来源:class.stataway.php

示例15: register

 /**
  * Checks post data and registers user
  * @return string
  */
 function register()
 {
     if (!empty($_REQUEST['register_ajax_widget'])) {
         $return = array();
         if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_REQUEST['user_login']) && !empty($_REQUEST['user_email'])) {
             //require_once( ABSPATH . WPINC . '/registration.php');
             // todo - recaptcha
             $errors = register_new_user($_POST['user_login'], $_POST['user_email']);
             if (!is_wp_error($errors)) {
                 //Success
                 // do they have an envato id?
                 if (isset($_REQUEST['envato_purchase_code']) && !empty($_REQUEST['envato_purchase_code'])) {
                     // add this based on tc plugin.
                 }
                 $user_data = get_userdata($errors);
                 $return['result'] = true;
                 $return['message'] = __(sprintf('Thank you %s. Registration is complete. Please check your e-mail.', $user_data->user_login));
             } else {
                 //Something's wrong
                 $return['result'] = false;
                 $return['error'] = $errors->get_error_message() . "<br>Username: " . htmlspecialchars(sanitize_user($_POST['user_login'], true));
             }
         }
         $return = json_encode($return);
         if (isset($_REQUEST['callback']) && preg_match("/^jQuery[_a-zA-Z0-9]+\$/", $_REQUEST['callback'])) {
             $return = $_GET['callback'] . "({$return})";
         }
         echo $return;
         exit;
     }
 }
开发者ID:paulmedwal,项目名称:edxforumspublic,代码行数:35,代码来源:bbps-register-widget.php


注:本文中的get_userdata函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。