本文整理汇总了PHP中bp_core_get_core_userdata函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_core_get_core_userdata函数的具体用法?PHP bp_core_get_core_userdata怎么用?PHP bp_core_get_core_userdata使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_core_get_core_userdata函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: owner
private function owner()
{
if (is_null($this->owner)) {
if (self::owner_type_user == $this->owner_type) {
$this->_owner = bp_core_get_core_userdata($this->owner_id);
} elseif (self::owner_type_group == $this->owner_type) {
$this->_owner = new BP_Groups_Group($this->owner_id);
}
}
return $this->_owner;
}
示例2: setup_globals
/**
* Setup globals
*
* The BP_MEMBERS_SLUG constant is deprecated, and only used here for
* backwards compatibility.
*
* @since 1.5
* @global obj $bp
*/
function setup_globals()
{
global $bp, $current_user, $displayed_user_id;
// Define a slug, if necessary
if (!defined('BP_MEMBERS_SLUG')) {
define('BP_MEMBERS_SLUG', $this->id);
}
$globals = array('path' => BP_PLUGIN_DIR, 'slug' => BP_MEMBERS_SLUG, 'root_slug' => isset($bp->pages->members->slug) ? $bp->pages->members->slug : BP_MEMBERS_SLUG, 'has_directory' => true, 'search_string' => __('Search Members...', 'buddypress'));
parent::setup_globals($globals);
/** Logged in user ****************************************************/
// Fetch the full name for the logged in user
$bp->loggedin_user->fullname = bp_core_get_user_displayname(bp_loggedin_user_id());
// Hits the DB on single WP installs so get this separately
$bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin(bp_loggedin_user_id());
// The domain for the user currently logged in. eg: http://domain.com/members/andy
$bp->loggedin_user->domain = bp_core_get_user_domain(bp_loggedin_user_id());
// The core userdata of the user who is currently logged in.
$bp->loggedin_user->userdata = bp_core_get_core_userdata(bp_loggedin_user_id());
/** Displayed user ****************************************************/
// The domain for the user currently being displayed
$bp->displayed_user->domain = bp_core_get_user_domain(bp_displayed_user_id());
// The core userdata of the user who is currently being displayed
$bp->displayed_user->userdata = bp_core_get_core_userdata(bp_displayed_user_id());
// Fetch the full name displayed user
$bp->displayed_user->fullname = bp_core_get_user_displayname(bp_displayed_user_id());
/** Profiles Fallback *************************************************/
if (!bp_is_active('xprofile')) {
$bp->profile->slug = 'profile';
$bp->profile->id = 'profile';
}
/** Default Profile Component *****************************************/
if (!defined('BP_DEFAULT_COMPONENT')) {
if (bp_is_active('activity') && isset($bp->pages->activity)) {
$bp->default_component = bp_get_activity_slug();
} else {
$bp->default_component = 'xprofile' == $bp->profile->id ? 'profile' : $bp->profile->id;
}
} else {
$bp->default_component = BP_DEFAULT_COMPONENT;
}
if (!bp_current_component() && bp_displayed_user_id()) {
/**
* BuddyPress will attempt to resolve to the most specific URL possible,
* to avoid search-engine-unfriendly content reduplication. Filter
* bp_guarantee_unique_uris (and return false) to avoid this behavior
*/
if (apply_filters('bp_guarantee_unique_uris', true)) {
bp_core_redirect(bp_displayed_user_domain() . $bp->default_component);
} else {
$bp->current_component = $bp->default_component;
}
}
}
示例3: setup_globals
/**
* Setup globals
*
* The BP_MEMBERS_SLUG constant is deprecated, and only used here for
* backwards compatibility.
*
* @since 1.5
* @global obj $bp
*/
function setup_globals()
{
global $bp, $current_user, $displayed_user_id;
// Define a slug, if necessary
if (!defined('BP_MEMBERS_SLUG')) {
define('BP_MEMBERS_SLUG', $this->id);
}
$globals = array('path' => BP_PLUGIN_DIR, 'slug' => BP_MEMBERS_SLUG, 'root_slug' => isset($bp->pages->members->slug) ? $bp->pages->members->slug : BP_MEMBERS_SLUG, 'has_directory' => true, 'search_string' => __('Search Members...', 'buddypress'));
parent::setup_globals($globals);
/** Logged in user ****************************************************/
// Fetch the full name for the logged in user
$bp->loggedin_user->fullname = bp_core_get_user_displayname($bp->loggedin_user->id);
// Hits the DB on single nxt installs so get this separately
$bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin();
// The domain for the user currently logged in. eg: http://domain.com/members/andy
$bp->loggedin_user->domain = bp_core_get_user_domain($bp->loggedin_user->id);
// The core userdata of the user who is currently logged in.
$bp->loggedin_user->userdata = bp_core_get_core_userdata($bp->loggedin_user->id);
/** Displayed user ****************************************************/
// The user id of the user currently being viewed:
// $bp->displayed_user->id is set in /bp-core/bp-core-catchuri.php
if (empty($bp->displayed_user->id)) {
$bp->displayed_user->id = 0;
}
// The domain for the user currently being displayed
$bp->displayed_user->domain = bp_core_get_user_domain($bp->displayed_user->id);
// The core userdata of the user who is currently being displayed
$bp->displayed_user->userdata = bp_core_get_core_userdata($bp->displayed_user->id);
// Fetch the full name displayed user
$bp->displayed_user->fullname = bp_core_get_user_displayname($bp->displayed_user->id);
/** Profiles Fallback *************************************************/
if (!bp_is_active('xprofile')) {
$bp->profile->slug = 'profile';
$bp->profile->id = 'profile';
}
/** Default Profile Component *****************************************/
if (!defined('BP_DEFAULT_COMPONENT')) {
if (bp_is_active('activity') && isset($bp->pages->activity)) {
$bp->default_component = bp_get_activity_slug();
} else {
$bp->default_component = 'xprofile' == $bp->profile->id ? 'profile' : $bp->profile->id;
}
} else {
$bp->default_component = BP_DEFAULT_COMPONENT;
}
if (!$bp->current_component && $bp->displayed_user->id) {
$bp->current_component = $bp->default_component;
}
}
示例4: bp_links_at_message_notification
function bp_links_at_message_notification($content, $poster_user_id, $link_id, $activity_id)
{
global $bp;
/* Scan for @username strings in an activity update. Notify each user. */
$pattern = '/[@]+([A-Za-z0-9-_]+)/';
preg_match_all($pattern, $content, $usernames);
/* Make sure there's only one instance of each username */
if (!($usernames = array_unique($usernames[1]))) {
return false;
}
$link = new BP_Links_Link($link_id);
foreach ((array) $usernames as $username) {
if (!($receiver_user_id = bp_core_get_userid($username))) {
continue;
}
if (!bp_links_is_link_visibile($link, $receiver_user_id)) {
continue;
}
// Now email the user with the contents of the message (if they have enabled email notifications)
if ('no' != get_usermeta($user_id, 'notification_activity_new_mention')) {
$poster_name = bp_core_get_user_displayname($poster_user_id);
$message_link = bp_activity_get_permalink($activity_id);
$settings_link = bp_core_get_user_domain($receiver_user_id) . 'settings/notifications/';
// Set up and send the message
$ud = bp_core_get_core_userdata($receiver_user_id);
$to = $ud->user_email;
$subject = '[' . get_blog_option(BP_ROOT_BLOG, 'blogname') . '] ' . sprintf(__('%s mentioned you in the link "%s"', 'buddypress-links'), stripslashes($poster_name), wp_filter_kses(stripslashes($link->name)));
$message = sprintf(__('%s mentioned you in the link "%s":
"%s"
To view and respond to the message, log in and visit: %s
---------------------
', 'buddypress-links'), $poster_name, wp_filter_kses(stripslashes_deep($link->name)), wp_filter_kses(stripslashes_deep($content)), $message_link);
$message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
// Send it
wp_mail($to, $subject, $message);
}
}
}
示例5: setup_globals
/**
* Set up bp-members global settings.
*
* The BP_MEMBERS_SLUG constant is deprecated, and only used here for
* backwards compatibility.
*
* @since BuddyPress (1.5.0)
*
* @see BP_Component::setup_globals() for description of parameters.
*
* @param array $args See {@link BP_Component::setup_globals()}.
*/
public function setup_globals($args = array())
{
$bp = buddypress();
/** Component Globals *************************************************/
// Define a slug, as a fallback for backpat
if (!defined('BP_MEMBERS_SLUG')) {
define('BP_MEMBERS_SLUG', $this->id);
}
// Override any passed args
$args = array('slug' => BP_MEMBERS_SLUG, 'root_slug' => isset($bp->pages->members->slug) ? $bp->pages->members->slug : BP_MEMBERS_SLUG, 'has_directory' => true, 'directory_title' => _x('Members', 'component directory title', 'buddypress'), 'search_string' => __('Search Members...', 'buddypress'), 'global_tables' => array('table_name_last_activity' => bp_core_get_table_prefix() . 'bp_activity', 'table_name_signups' => bp_core_get_table_prefix() . 'signups'));
parent::setup_globals($args);
/** Logged in user ****************************************************/
// The core userdata of the user who is currently logged in.
$bp->loggedin_user->userdata = bp_core_get_core_userdata(bp_loggedin_user_id());
// Fetch the full name for the logged in user
$bp->loggedin_user->fullname = isset($bp->loggedin_user->userdata->display_name) ? $bp->loggedin_user->userdata->display_name : '';
// Hits the DB on single WP installs so get this separately
$bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin(bp_loggedin_user_id());
// The domain for the user currently logged in. eg: http://example.com/members/andy
$bp->loggedin_user->domain = bp_core_get_user_domain(bp_loggedin_user_id());
/** Displayed user ****************************************************/
// The core userdata of the user who is currently being displayed
$bp->displayed_user->userdata = bp_core_get_core_userdata(bp_displayed_user_id());
// Fetch the full name displayed user
$bp->displayed_user->fullname = isset($bp->displayed_user->userdata->display_name) ? $bp->displayed_user->userdata->display_name : '';
// The domain for the user currently being displayed
$bp->displayed_user->domain = bp_core_get_user_domain(bp_displayed_user_id());
/** Signup ************************************************************/
$bp->signup = new stdClass();
/** Profiles Fallback *************************************************/
if (!bp_is_active('xprofile')) {
$bp->profile = new stdClass();
$bp->profile->slug = 'profile';
$bp->profile->id = 'profile';
}
}
示例6: bp_blogs_sync_add_from_activity_comment
/**
* Syncs activity comments and posts them back as blog comments.
*
* Note: This is only a one-way sync - activity comments -> blog comment.
*
* For blog post -> activity comment, see {@link bp_activity_post_type_comment()}.
*
* @since 2.0.0
* @since 2.5.0 Allow custom post types to sync their comments with activity ones
*
* @param int $comment_id The activity ID for the posted activity comment.
* @param array $params Parameters for the activity comment.
* @param object $parent_activity Parameters of the parent activity item (in this case, the blog post).
*/
function bp_blogs_sync_add_from_activity_comment($comment_id, $params, $parent_activity)
{
// if parent activity isn't a post type having the buddypress-activity support, stop now!
if (!bp_activity_type_supports($parent_activity->type, 'post-type-comment-tracking')) {
return;
}
// If activity comments are disabled for blog posts, stop now!
if (bp_disable_blogforum_comments()) {
return;
}
// Get userdata.
if ($params['user_id'] == bp_loggedin_user_id()) {
$user = buddypress()->loggedin_user->userdata;
} else {
$user = bp_core_get_core_userdata($params['user_id']);
}
// Get associated post type and set default comment parent
$post_type = bp_activity_post_type_get_tracking_arg($parent_activity->type, 'post_type');
$comment_parent = 0;
// See if a parent WP comment ID exists.
if (!empty($params['parent_id']) && !empty($post_type)) {
$comment_parent = bp_activity_get_meta($params['parent_id'], "bp_blogs_{$post_type}_comment_id");
}
// Comment args.
$args = array('comment_post_ID' => $parent_activity->secondary_item_id, 'comment_author' => bp_core_get_user_displayname($params['user_id']), 'comment_author_email' => $user->user_email, 'comment_author_url' => bp_core_get_user_domain($params['user_id'], $user->user_nicename, $user->user_login), 'comment_content' => $params['content'], 'comment_type' => '', 'comment_parent' => (int) $comment_parent, 'user_id' => $params['user_id'], 'comment_approved' => 1);
// Prevent separate activity entry being made.
remove_action('comment_post', 'bp_activity_post_type_comment', 10, 2);
// Handle multisite.
switch_to_blog($parent_activity->item_id);
// Handle timestamps for the WP comment after we've switched to the blog.
$args['comment_date'] = current_time('mysql');
$args['comment_date_gmt'] = current_time('mysql', 1);
// Post the comment.
$post_comment_id = wp_insert_comment($args);
// Add meta to comment.
add_comment_meta($post_comment_id, 'bp_activity_comment_id', $comment_id);
// Add meta to activity comment.
if (!empty($post_type)) {
bp_activity_update_meta($comment_id, "bp_blogs_{$post_type}_comment_id", $post_comment_id);
}
// Resave activity comment with WP comment permalink.
//
// in bp_blogs_activity_comment_permalink(), we change activity comment
// permalinks to use the post comment link
//
// @todo since this is done after AJAX posting, the activity comment permalink
// doesn't change on the frontend until the next page refresh.
$resave_activity = new BP_Activity_Activity($comment_id);
$resave_activity->primary_link = get_comment_link($post_comment_id);
/**
* Now that the activity id exists and the post comment was created, we don't need to update
* the content of the comment as there are no chances it has evolved.
*/
remove_action('bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20);
$resave_activity->save();
// Add the edit activity comment hook back.
add_action('bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20);
// Multisite again!
restore_current_blog();
// Add the comment hook back.
add_action('comment_post', 'bp_activity_post_type_comment', 10, 2);
/**
* Fires after activity comments have been synced and posted as blog comments.
*
* @since 2.0.0
*
* @param int $comment_id The activity ID for the posted activity comment.
* @param array $args Array of args used for the comment syncing.
* @param object $parent_activity Parameters of the blog post parent activity item.
* @param object $user User data object for the blog comment.
*/
do_action('bp_blogs_sync_add_from_activity_comment', $comment_id, $args, $parent_activity, $user);
}
示例7: save_quiz_coverage
/**
* save_quiz_coverage( $results )
* Hooks into `courseware_response_added` and saves a coverage result on quiz submission
*
* @param Mixed $results, the response data and quiz rezult
*/
function save_quiz_coverage($results)
{
global $bp;
if (isset($results['response']) && isset($results['response']->form_values)) {
$gradebook = $this->has_gradebook($results['response']->post_parent);
$quiz_data = $results['response']->form_values;
$grade = array('uid' => $results['response']->post_author, 'value' => isset($form_results['correct']) && $form_results['correct'] > 0 ? round($quiz_data['correct'] / $quiz_data['total'] * 100, 2) : 0, 'format' => 'percentage', 'prv_comment' => $results['response']->post_title, 'pub_comment' => $results['response']->post_content);
if ($gradebook) {
$status = $this->save_grade($gradebook, $grade);
$data = array('grade' => $grade, 'teacher' => bp_core_get_core_userdata($bp->groups->current_group->creator_id), 'assignment' => $this->current_assignment);
if ($status == true) {
do_action('courseware_grade_added', $data);
} else {
do_action('courseware_grade_updated', $data);
}
}
}
}
示例8: setup_globals
/**
* Set up bp-members global settings.
*
* The BP_MEMBERS_SLUG constant is deprecated, and only used here for
* backwards compatibility.
*
* @since 1.5.0
*
* @see BP_Component::setup_globals() for description of parameters.
*
* @param array $args See {@link BP_Component::setup_globals()}.
*/
public function setup_globals($args = array())
{
global $wpdb;
$bp = buddypress();
/** Component Globals ************************************************
*/
// Define a slug, as a fallback for backpat.
if (!defined('BP_MEMBERS_SLUG')) {
define('BP_MEMBERS_SLUG', $this->id);
}
// Fetch the default directory title.
$default_directory_titles = bp_core_get_directory_page_default_titles();
$default_directory_title = $default_directory_titles[$this->id];
// Override any passed args.
$args = array('slug' => BP_MEMBERS_SLUG, 'root_slug' => isset($bp->pages->members->slug) ? $bp->pages->members->slug : BP_MEMBERS_SLUG, 'has_directory' => true, 'directory_title' => isset($bp->pages->members->title) ? $bp->pages->members->title : $default_directory_title, 'search_string' => __('Search Members...', 'buddypress'), 'global_tables' => array('table_name_last_activity' => bp_core_get_table_prefix() . 'bp_activity', 'table_name_signups' => $wpdb->base_prefix . 'signups'));
parent::setup_globals($args);
/** Logged in user ***************************************************
*/
// The core userdata of the user who is currently logged in.
$bp->loggedin_user->userdata = bp_core_get_core_userdata(bp_loggedin_user_id());
// Fetch the full name for the logged in user.
$bp->loggedin_user->fullname = isset($bp->loggedin_user->userdata->display_name) ? $bp->loggedin_user->userdata->display_name : '';
// Hits the DB on single WP installs so get this separately.
$bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin(bp_loggedin_user_id());
// The domain for the user currently logged in. eg: http://example.com/members/andy.
$bp->loggedin_user->domain = bp_core_get_user_domain(bp_loggedin_user_id());
/** Displayed user ***************************************************
*/
// The core userdata of the user who is currently being displayed.
$bp->displayed_user->userdata = bp_core_get_core_userdata(bp_displayed_user_id());
// Fetch the full name displayed user.
$bp->displayed_user->fullname = isset($bp->displayed_user->userdata->display_name) ? $bp->displayed_user->userdata->display_name : '';
// The domain for the user currently being displayed.
$bp->displayed_user->domain = bp_core_get_user_domain(bp_displayed_user_id());
// Initialize the nav for the members component.
$this->nav = new BP_Core_Nav();
// If A user is displayed, check if there is a front template
if (bp_get_displayed_user()) {
$bp->displayed_user->front_template = bp_displayed_user_get_front_template();
}
/** Signup ***********************************************************
*/
$bp->signup = new stdClass();
/** Profiles Fallback ************************************************
*/
if (!bp_is_active('xprofile')) {
$bp->profile = new stdClass();
$bp->profile->slug = 'profile';
$bp->profile->id = 'profile';
}
}
示例9: bp_activity_get_user_mentionname
/**
* Determine a user's "mentionname", the name used for that user in @-mentions.
*
* @since BuddyPress (1.9.0)
*
* @return string User name appropriate for @-mentions.
*/
function bp_activity_get_user_mentionname($user_id)
{
$mentionname = '';
$userdata = bp_core_get_core_userdata($user_id);
if ($userdata) {
if (bp_is_username_compatibility_mode()) {
$mentionname = str_replace(' ', '-', $userdata->user_login);
} else {
$mentionname = $userdata->user_nicename;
}
}
return $mentionname;
}
示例10: bp_activity_new_comment_notification
/**
* Send email and BP notifications when an activity item receives a comment.
*
* @since 1.2.0
*
* @uses bp_get_user_meta()
* @uses bp_core_get_user_displayname()
* @uses bp_activity_get_permalink()
* @uses bp_core_get_user_domain()
* @uses bp_get_settings_slug()
* @uses bp_activity_filter_kses()
* @uses bp_core_get_core_userdata()
* @uses wp_specialchars_decode()
* @uses get_blog_option()
* @uses bp_get_root_blog_id()
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_to' hook.
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_subject' hook.
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_message' hook.
* @uses wp_mail()
* @uses do_action() To call the 'bp_activity_sent_reply_to_update_email' hook.
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_to' hook.
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_subject' hook.
* @uses apply_filters() To call the 'bp_activity_new_comment_notification_comment_author_message' hook.
* @uses do_action() To call the 'bp_activity_sent_reply_to_reply_email' hook.
*
* @param int $comment_id The comment id.
* @param int $commenter_id The ID of the user who posted the comment.
* @param array $params {@link bp_activity_new_comment()}.
* @return bool
*/
function bp_activity_new_comment_notification($comment_id = 0, $commenter_id = 0, $params = array())
{
// Set some default parameters.
$activity_id = 0;
$parent_id = 0;
extract($params);
$original_activity = new BP_Activity_Activity($activity_id);
if ($original_activity->user_id != $commenter_id && 'no' != bp_get_user_meta($original_activity->user_id, 'notification_activity_new_reply', true)) {
$poster_name = bp_core_get_user_displayname($commenter_id);
$thread_link = bp_activity_get_permalink($activity_id);
$settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
$settings_link = bp_core_get_user_domain($original_activity->user_id) . $settings_slug . '/notifications/';
$poster_name = stripslashes($poster_name);
$content = bp_activity_filter_kses(stripslashes($content));
// Set up and send the message.
$ud = bp_core_get_core_userdata($original_activity->user_id);
$to = $ud->user_email;
$subject = bp_get_email_subject(array('text' => sprintf(__('%s replied to one of your updates', 'buddypress'), $poster_name)));
$message = sprintf(__('%1$s replied to one of your updates:
"%2$s"
To view your original update and all comments, log in and visit: %3$s
---------------------
', 'buddypress'), $poster_name, $content, $thread_link);
// Only show the disable notifications line if the settings component is enabled.
if (bp_is_active('settings')) {
$message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
}
/**
* Filters the user email that the new comment notification will be sent to.
*
* @since 1.2.0
*
* @param string $to User email the notification is being sent to.
*/
$to = apply_filters('bp_activity_new_comment_notification_to', $to);
/**
* Filters the new comment notification subject that will be sent to user.
*
* @since 1.2.0
*
* @param string $subject Email notification subject text.
* @param string $poster_name Name of the person who made the comment.
*/
$subject = apply_filters('bp_activity_new_comment_notification_subject', $subject, $poster_name);
/**
* Filters the new comment notification message that will be sent to user.
*
* @since 1.2.0
*
* @param string $message Email notification message text.
* @param string $poster_name Name of the person who made the comment.
* @param string $content Content of the comment.
* @param string $thread_link URL permalink for the activity thread.
* @param string $settings_link URL permalink for the user's notification settings area.
*/
$message = apply_filters('bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link);
wp_mail($to, $subject, $message);
/**
* Fires after the sending of a reply to an update email notification.
*
* @since 1.5.0
*
* @param int $user_id ID of the original activity item author.
* @param string $subject Email notification subject text.
* @param string $message Email notification message text.
* @param int $comment_id ID for the newly received comment.
* @param int $commenter_id ID of the user who made the comment.
//.........这里部分代码省略.........
示例11: bp_group_documents_email_notification
/**
* bp_group_documents_email_notificiation()
*
* This function will send email notifications to users on successful document upload.
* For each group memeber, it 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.
*/
function bp_group_documents_email_notification($document)
{
global $bp;
$user_name = bp_core_get_userlink($bp->loggedin_user->id, true);
$user_profile_link = bp_core_get_userlink($bp->loggedin_user->id, false, true);
$group_name = $bp->groups->current_group->name;
$group_link = bp_get_group_permalink($bp->groups->current_group);
$document_name = $document->name;
$document_link = $document->get_url();
$subject = '[' . get_blog_option(1, 'blogname') . '] ' . sprintf(__('A document was uploaded to %s', 'bp-group-documents'), $bp->groups->current_group->name);
//these will be all the emails getting the update
//'user_id' => 'user_email
$emails = array();
//first get the admin & moderator emails
if (count($bp->groups->current_group->admins)) {
foreach ($bp->groups->current_group->admins as $user) {
if ('no' == get_user_meta($user->user_id, 'notification_group_documents_upload_mod')) {
continue;
}
$emails[$user->user_id] = $user->user_email;
}
}
if (count($bp->groups->current_group->mods)) {
foreach ($bp->groups->current_group->mods as $user) {
if ('no' == get_user_meta($user->user_id, 'notification_group_documents_upload_mod')) {
continue;
}
if (!in_array($user->user_email, $emails)) {
$emails[$user->user_id] = $user->user_email;
}
}
}
//now get all member emails, checking to make sure not to send any emails twice
$user_ids = BP_Groups_Member::get_group_member_ids($bp->groups->current_group->id);
foreach ((array) $user_ids as $user_id) {
if ('no' == get_user_meta($user_id, 'notification_group_documents_upload_member')) {
continue;
}
$ud = bp_core_get_core_userdata($user_id);
if (!in_array($ud->user_email, $emails)) {
$emails[$user_id] = $ud->user_email;
}
}
foreach ($emails as $current_id => $current_email) {
$message = sprintf(__('%s uploaded a new file: %s to the group: %s.
To see %s\'s profile: %s
To see the group %s\'s homepage: %s
To download the new document directly: %s
------------------------
', 'bp-group-documents'), $user_name, $document_name, $group_name, $user_name, $user_profile_link, $group_name, $group_link, $document_link);
$settings_link = bp_core_get_user_domain($current_id) . $bp->settings->slug . '/notifications/';
$message .= sprintf(__('To disable these notifications please log in and go to: %s', 'bp-group-documents'), $settings_link);
// Set up and send the message
$to = $current_email;
wp_mail($to, $subject, $message);
unset($to, $message);
}
//end foreach
}
示例12: bp_core_get_user_email
/**
* Return the email address for the user based on user ID.
*
* @since 1.0.0
*
* @param int $uid User ID to check.
* @return string The email for the matched user. Empty string if no user
* matched the $uid.
*/
function bp_core_get_user_email($uid)
{
if (!($email = wp_cache_get('bp_user_email_' . $uid, 'bp'))) {
// User exists.
$ud = bp_core_get_core_userdata($uid);
if (!empty($ud)) {
$email = $ud->user_email;
// User was deleted.
} else {
$email = '';
}
wp_cache_set('bp_user_email_' . $uid, $email, 'bp');
}
/**
* Filters the user email for user based on user ID.
*
* @since 1.0.1
*
* @param string $email Email determined for the user.
*/
return apply_filters('bp_core_get_user_email', $email);
}
示例13: bp_settings_action_general
//.........这里部分代码省略.........
// Password change attempt is successful.
if (!empty($_POST['pwd']) && $_POST['pwd'] != $_POST['pass1'] || is_super_admin()) {
$update_user->user_pass = $_POST['pass1'];
$pass_changed = true;
// The new password is the same as the current password.
} else {
$pass_error = 'same';
}
// Password change attempt was unsuccessful.
} else {
$pass_error = 'mismatch';
}
// Both password fields were empty.
} elseif (empty($_POST['pass1']) && empty($_POST['pass2'])) {
$pass_error = false;
// One of the password boxes was left empty.
} elseif (empty($_POST['pass1']) && !empty($_POST['pass2']) || !empty($_POST['pass1']) && empty($_POST['pass2'])) {
$pass_error = 'empty';
}
// The structure of the $update_user object changed in WP 3.3, but
// wp_update_user() still expects the old format.
if (isset($update_user->data) && is_object($update_user->data)) {
$update_user = $update_user->data;
$update_user = get_object_vars($update_user);
// Unset the password field to prevent it from emptying out the
// user's user_pass field in the database.
// @see wp_update_user().
if (false === $pass_changed) {
unset($update_user['user_pass']);
}
}
// Clear cached data, so that the changed settings take effect
// on the current page load.
if (false === $email_error && false === $pass_error && wp_update_user($update_user)) {
wp_cache_delete('bp_core_userdata_' . bp_displayed_user_id(), 'bp');
$bp->displayed_user->userdata = bp_core_get_core_userdata(bp_displayed_user_id());
}
// Password Error.
} else {
$pass_error = 'invalid';
}
// Email feedback.
switch ($email_error) {
case 'invalid':
$feedback['email_invalid'] = __('That email address is invalid. Check the formatting and try again.', 'buddypress');
break;
case 'blocked':
$feedback['email_blocked'] = __('That email address is currently unavailable for use.', 'buddypress');
break;
case 'taken':
$feedback['email_taken'] = __('That email address is already taken.', 'buddypress');
break;
case 'empty':
$feedback['email_empty'] = __('Email address cannot be empty.', 'buddypress');
break;
case false:
// No change.
break;
}
// Password feedback.
switch ($pass_error) {
case 'invalid':
$feedback['pass_error'] = __('Your current password is invalid.', 'buddypress');
break;
case 'mismatch':
$feedback['pass_mismatch'] = __('The new password fields did not match.', 'buddypress');
break;
case 'empty':
$feedback['pass_empty'] = __('One of the password fields was empty.', 'buddypress');
break;
case 'same':
$feedback['pass_same'] = __('The new password must be different from the current password.', 'buddypress');
break;
case false:
// No change.
break;
}
// No errors so show a simple success message.
if ((false === $email_error || false == $pass_error) && (true === $pass_changed || true === $email_changed)) {
$feedback[] = __('Your settings have been saved.', 'buddypress');
$feedback_type = 'success';
// Some kind of errors occurred.
} elseif ((false === $email_error || false === $pass_error) && (false === $pass_changed || false === $email_changed)) {
if (bp_is_my_profile()) {
$feedback['nochange'] = __('No changes were made to your account.', 'buddypress');
} else {
$feedback['nochange'] = __('No changes were made to this account.', 'buddypress');
}
}
// Set the feedback.
bp_core_add_message(implode("\n", $feedback), $feedback_type);
/**
* Fires after the general settings have been saved, and before redirect.
*
* @since 1.5.0
*/
do_action('bp_core_general_settings_after_save');
// Redirect to prevent issues with browser back button.
bp_core_redirect(trailingslashit(bp_displayed_user_domain() . bp_get_settings_slug() . '/general'));
}
示例14: bp_blogs_sync_add_from_activity_comment
/**
* Syncs activity comments and posts them back as blog comments.
*
* Note: This is only a one-way sync - activity comments -> blog comment.
*
* For blog post -> activity comment, see {@link bp_blogs_record_comment()}.
*
* @since BuddyPress (2.0.0)
*
* @param int $comment_id The activity ID for the posted activity comment.
* @param array $params Parameters for the activity comment.
* @param object Parameters of the parent activity item (in this case, the blog post).
*/
function bp_blogs_sync_add_from_activity_comment( $comment_id, $params, $parent_activity ) {
// if parent activity isn't a blog post, stop now!
if ( $parent_activity->type != 'new_blog_post' ) {
return;
}
// if activity comments are disabled for blog posts, stop now!
if ( bp_disable_blogforum_comments() ) {
return;
}
// get userdata
if ( $params['user_id'] == bp_loggedin_user_id() ) {
$user = buddypress()->loggedin_user->userdata;
} else {
$user = bp_core_get_core_userdata( $params['user_id'] );
}
// see if a parent WP comment ID exists
if ( ! empty( $params['parent_id'] ) ) {
$comment_parent = bp_activity_get_meta( $params['parent_id'], 'bp_blogs_post_comment_id' );
} else {
$comment_parent = 0;
}
// comment args
$args = array(
'comment_post_ID' => $parent_activity->secondary_item_id,
'comment_author' => bp_core_get_user_displayname( $params['user_id'] ),
'comment_author_email' => $user->user_email,
'comment_author_url' => bp_core_get_user_domain( $params['user_id'], $user->user_nicename, $user->user_login ),
'comment_content' => $params['content'],
'comment_type' => '', // could be interesting to add 'buddypress' here...
'comment_parent' => (int) $comment_parent,
'user_id' => $params['user_id'],
// commenting these out for now
//'comment_author_IP' => '127.0.0.1',
//'comment_agent' => '',
'comment_approved' => 1
);
// prevent separate activity entry being made
remove_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
// handle multisite
switch_to_blog( $parent_activity->item_id );
// handle timestamps for the WP comment after we've switched to the blog
$args['comment_date'] = current_time( 'mysql' );
$args['comment_date_gmt'] = current_time( 'mysql', 1 );
// post the comment
$post_comment_id = wp_insert_comment( $args );
// add meta to comment
add_comment_meta( $post_comment_id, 'bp_activity_comment_id', $comment_id );
// add meta to activity comment
bp_activity_update_meta( $comment_id, 'bp_blogs_post_comment_id', $post_comment_id );
// resave activity comment with WP comment permalink
//
// in bp_blogs_activity_comment_permalink(), we change activity comment
// permalinks to use the post comment link
//
// @todo since this is done after AJAX posting, the activity comment permalink
// doesn't change on the frontend until the next page refresh.
$resave_activity = new BP_Activity_Activity( $comment_id );
$resave_activity->primary_link = get_comment_link( $post_comment_id );
$resave_activity->save();
// multisite again!
restore_current_blog();
// add the comment hook back
add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
/**
* Fires after activity comments have been synced and posted as blog comments.
*
* @since BuddyPress (2.0.0)
*
* @param int $comment_id The activity ID for the posted activity comment.
* @param array $args Array of args used for the comment syncing.
* @param object $parent_activity Parameters of the blog post parent activity item.
//.........这里部分代码省略.........
示例15: groups_notification_group_invites
function groups_notification_group_invites(&$group, &$member, $inviter_user_id)
{
global $bp;
$inviter_ud = bp_core_get_core_userdata($inviter_user_id);
$inviter_name = bp_core_get_userlink($inviter_user_id, true, false, true);
$inviter_link = bp_core_get_user_domain($inviter_user_id);
$group_link = bp_get_group_permalink($group);
if (!$member->invite_sent) {
$invited_user_id = $member->user_id;
// Post a screen notification first.
bp_core_add_notification($group->id, $invited_user_id, 'groups', 'group_invite');
if ('no' == bp_get_user_meta($invited_user_id, 'notification_groups_invite', true)) {
return false;
}
$invited_ud = bp_core_get_core_userdata($invited_user_id);
$settings_link = bp_core_get_user_domain($invited_user_id) . bp_get_settings_slug() . '/notifications/';
$invited_link = bp_core_get_user_domain($invited_user_id);
$invites_link = $invited_link . bp_get_groups_slug() . '/invites';
// Set up and send the message
$to = $invited_ud->user_email;
$sitename = wp_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
$subject = '[' . $sitename . '] ' . sprintf(__('You have an invitation to the group: "%s"', 'buddypress'), $group->name);
$message = sprintf(__('One of your friends %1$s has invited you to the group: "%2$s".
To view your group invites visit: %3$s
To view the group visit: %4$s
To view %5$s\'s profile visit: %6$s
---------------------
', 'buddypress'), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link);
$message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
/* Send the message */
$to = apply_filters('groups_notification_group_invites_to', $to);
$subject = apply_filters_ref_array('groups_notification_group_invites_subject', array($subject, &$group));
$message = apply_filters_ref_array('groups_notification_group_invites_message', array($message, &$group, $inviter_name, $inviter_link, $invites_link, $group_link, $settings_link));
wp_mail($to, $subject, $message);
do_action('bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group);
}
}