Beispiel #1
1
 /**
  * @group xprofile_set_field_data
  * @ticket BP5836
  */
 public function test_xprofile_sync_bp_profile_new_user()
 {
     $post_vars = $_POST;
     $_POST = array('user_login' => 'foobar', 'pass1' => 'password', 'pass2' => 'password', 'role' => 'subscriber', 'email' => '*****@*****.**', 'first_name' => 'Foo', 'last_name' => 'Bar');
     $id = add_user();
     $display_name = 'Bar Foo';
     $_POST = array('display_name' => $display_name, 'email' => '*****@*****.**', 'nickname' => 'foobar');
     $id = edit_user($id);
     // clean up post vars
     $_POST = $post_vars;
     $this->assertEquals($display_name, xprofile_get_field_data(bp_xprofile_fullname_field_id(), $id));
 }
function cfbgr_migrate_xprofile_as_member_types()
{
    global $wpdb;
    $buddypress = buddypress();
    // Description of this tool, displayed to the user
    $statement = __('Migrating/Resetting xProfile data as member types: %s', 'buddypress-group-restrictions');
    // Default to failure text
    $result = __('No xProfile data needs to be migrated or reset.', 'buddypress-group-restrictions');
    // Default to unrepaired
    $repair = 0;
    $field = (int) bp_get_option('cfbgr_xfield_id', 0);
    if (empty($field)) {
        return array(0, sprintf($statement, $result));
    }
    $member_types = bp_get_member_types();
    // Walk through all users on the site
    $user_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->users}");
    foreach ($user_ids as $user_id) {
        $value = sanitize_key(xprofile_get_field_data($field, $user_id));
        // Do we have a matching member type ?
        if (isset($member_types[$value])) {
            // Set member types if empty or different
            if ($value !== bp_get_member_type($user_id)) {
                bp_set_member_type($user_id, $value);
                $repair += 1;
            }
        }
    }
    $result = sprintf(__('%d migrated or reset', 'buddypress-group-restrictions'), $repair);
    // All done!
    return array(0, sprintf($statement, $result));
}
function openlab_user_is_admin($is_admin)
{
    $account_type = xprofile_get_field_data('Account Type', get_current_user_id());
    if ($account_type && 'Faculty' == $account_type) {
        $is_admin = true;
    }
    return $is_admin;
}
/**
 * Adiciona campos no perfil do usuário
 *
 * @param void
 * @return string
 */
function display_user_color_pref()
{
    $bp_profissao = xprofile_get_field_data('profissão');
    $bp_cidade = xprofile_get_field_data('cidade');
    $bp_estado = xprofile_get_field_data('estado');
    echo '<p class="field-data">' . $bp_profissao . '</p>';
    echo '<p class="field-data">' . $bp_cidade . ' - ' . $bp_estado . '</p>';
}
 function rtmedia_api_user_data_from_id($user_id, $width = 80, $height = 80, $type = 'thumb')
 {
     if (empty($user_id)) {
         return false;
     }
     $user_data = array();
     $user_data['id'] = $user_id;
     $user_data['name'] = xprofile_get_field_data('Name', $user_id);
     $avatar_args = array('item_id' => $user_id, 'width' => $width, 'height' => $height, 'html' => false, 'alt' => '', 'type' => $type);
     $user_data['avatar'] = bp_core_fetch_avatar($avatar_args);
     return $user_data;
 }
function xprofile_sync_wp_profile()
{
    global $bp, $wpdb;
    if ((int) get_site_option('bp-disable-profile-sync')) {
        return true;
    }
    $fullname = xprofile_get_field_data(BP_XPROFILE_FULLNAME_FIELD_NAME, $bp->loggedin_user->id);
    $space = strpos($fullname, ' ');
    if (false === $space) {
        $firstname = $fullname;
        $lastname = '';
    } else {
        $firstname = substr($fullname, 0, $space);
        $lastname = trim(substr($fullname, $space, strlen($fullname)));
    }
    update_usermeta($bp->loggedin_user->id, 'nickname', $fullname);
    update_usermeta($bp->loggedin_user->id, 'first_name', $firstname);
    update_usermeta($bp->loggedin_user->id, 'last_name', $lastname);
    $wpdb->query($wpdb->prepare("UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $bp->loggedin_user->id));
    $wpdb->query($wpdb->prepare("UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d", bp_core_get_user_domain($bp->loggedin_user->id), $bp->loggedin_user->id));
}
/**
 * Handles the display of the profile edit page by loading the correct template file.
 * Also checks to make sure this can only be accessed for the logged in users profile.
 *
 * @package BuddyPress XProfile
 * @uses bp_is_my_profile() Checks to make sure the current user being viewed equals the logged in user
 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
 */
function xprofile_screen_edit_profile()
{
    if (!bp_is_my_profile() && !bp_current_user_can('bp_moderate')) {
        return false;
    }
    $bp = buddypress();
    // Make sure a group is set.
    if (!bp_action_variable(1)) {
        bp_core_redirect(trailingslashit(bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/1'));
    }
    // Check the field group exists
    if (!bp_is_action_variable('group') || !xprofile_get_field_group(bp_action_variable(1))) {
        bp_do_404();
        return;
    }
    // No errors
    $errors = false;
    // Check to see if any new information has been submitted
    if (isset($_POST['field_ids'])) {
        // Check the nonce
        check_admin_referer('bp_xprofile_edit');
        // Check we have field ID's
        if (empty($_POST['field_ids'])) {
            bp_core_redirect(trailingslashit(bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/' . bp_action_variable(1)));
        }
        // Explode the posted field IDs into an array so we know which
        // fields have been submitted
        $posted_field_ids = wp_parse_id_list($_POST['field_ids']);
        $is_required = array();
        // Loop through the posted fields formatting any datebox values
        // then validate the field
        foreach ((array) $posted_field_ids as $field_id) {
            if (!isset($_POST['field_' . $field_id])) {
                if (!empty($_POST['field_' . $field_id . '_day']) && !empty($_POST['field_' . $field_id . '_month']) && !empty($_POST['field_' . $field_id . '_year'])) {
                    // Concatenate the values
                    $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
                    // Turn the concatenated value into a timestamp
                    $_POST['field_' . $field_id] = date('Y-m-d H:i:s', strtotime($date_value));
                }
            }
            $is_required[$field_id] = xprofile_check_is_required_field($field_id);
            if ($is_required[$field_id] && empty($_POST['field_' . $field_id])) {
                $errors = true;
            }
        }
        // There are errors
        if (!empty($errors)) {
            bp_core_add_message(__('Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress'), 'error');
            // No errors
        } else {
            // Reset the errors var
            $errors = false;
            // Now we've checked for required fields, lets save the values.
            $old_values = $new_values = array();
            foreach ((array) $posted_field_ids as $field_id) {
                // Certain types of fields (checkboxes, multiselects) may come through empty. Save them as an empty array so that they don't get overwritten by the default on the next edit.
                $value = isset($_POST['field_' . $field_id]) ? $_POST['field_' . $field_id] : '';
                $visibility_level = !empty($_POST['field_' . $field_id . '_visibility']) ? $_POST['field_' . $field_id . '_visibility'] : 'public';
                // Save the old and new values. They will be
                // passed to the filter and used to determine
                // whether an activity item should be posted
                $old_values[$field_id] = array('value' => xprofile_get_field_data($field_id, bp_displayed_user_id()), 'visibility' => xprofile_get_field_visibility_level($field_id, bp_displayed_user_id()));
                // Update the field data and visibility level
                xprofile_set_field_visibility_level($field_id, bp_displayed_user_id(), $visibility_level);
                $field_updated = xprofile_set_field_data($field_id, bp_displayed_user_id(), $value, $is_required[$field_id]);
                $value = xprofile_get_field_data($field_id, bp_displayed_user_id());
                $new_values[$field_id] = array('value' => $value, 'visibility' => xprofile_get_field_visibility_level($field_id, bp_displayed_user_id()));
                if (!$field_updated) {
                    $errors = true;
                } else {
                    /**
                     * Fires on each iteration of an XProfile field being saved with no error.
                     *
                     * @since BuddyPress (1.1.0)
                     *
                     * @param int    $field_id ID of the field that was saved.
                     * @param string $value    Value that was saved to the field.
                     */
                    do_action('xprofile_profile_field_data_updated', $field_id, $value);
                }
            }
            /**
             * Fires after all XProfile fields have been saved for the current profile.
             *
             * @since BuddyPress (1.0.0)
             *
             * @param int   $value            Displayed user ID.
             * @param array $posted_field_ids Array of field IDs that were edited.
             * @param bool  $errors           Whether or not any errors occurred.
             * @param array $old_values       Array of original values before updated.
             * @param array $new_values       Array of newly saved values after update.
             */
            do_action('xprofile_updated_profile', bp_displayed_user_id(), $posted_field_ids, $errors, $old_values, $new_values);
            // Set the feedback messages
            if (!empty($errors)) {
                bp_core_add_message(__('There was a problem updating some of your profile information. Please try again.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Changes saved.', 'buddypress'));
            }
            // Redirect back to the edit screen to display the updates and message
            bp_core_redirect(trailingslashit(bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/' . bp_action_variable(1)));
        }
    }
    /**
     * Fires right before the loading of the XProfile edit screen template file.
     *
     * @since BuddyPress (1.0.0)
     */
    do_action('xprofile_screen_edit_profile');
    /**
     * Filters the template to load for the XProfile edit screen.
     *
     * @since BuddyPress (1.0.0)
     *
     * @param string $template Path to the XProfile edit template to load.
     */
    bp_core_load_template(apply_filters('xprofile_template_edit_profile', 'members/single/home'));
}
/**
 * Fetch the display name for a user. This will use the "Name" field in xprofile if it is installed.
 * Otherwise, it will fall back to the normal WP display_name, or user_nicename, depending on what has been set.
 *
 * @package BuddyPress Core
 * @global object $bp Global BuddyPress settings object
 * @uses wp_cache_get() Will try and fetch the value from the cache, rather than querying the DB again.
 * @uses get_userdata() Fetches the WP userdata for a specific user.
 * @uses xprofile_set_field_data() Will update the field data for a user based on field name and user id.
 * @uses wp_cache_set() Adds a value to the cache.
 * @return str The display name for the user in question.
 */
function bp_core_get_user_displayname($user_id_or_username)
{
    global $bp;
    $fullname = '';
    if (!$user_id_or_username) {
        return false;
    }
    if (!is_numeric($user_id_or_username)) {
        $user_id = bp_core_get_userid($user_id_or_username);
    } else {
        $user_id = $user_id_or_username;
    }
    if (!$user_id) {
        return false;
    }
    if (!($fullname = wp_cache_get('bp_user_fullname_' . $user_id, 'bp'))) {
        if (bp_is_active('xprofile')) {
            $fullname = xprofile_get_field_data(stripslashes($bp->site_options['bp-xprofile-fullname-field-name']), $user_id);
            if (empty($fullname)) {
                $ud = bp_core_get_core_userdata($user_id);
                if (!empty($ud->display_name)) {
                    $fullname = $ud->display_name;
                } elseif (!empty($ud->user_nicename)) {
                    $fullname = $ud->user_nicename;
                }
                xprofile_set_field_data(1, $user_id, $fullname);
            }
        } else {
            $ud = bp_core_get_core_userdata($user_id);
            if (!empty($ud->display_name)) {
                $fullname = $ud->display_name;
            } elseif (!empty($ud->user_nicename)) {
                $fullname = $ud->user_nicename;
            }
        }
        if (!empty($fullname)) {
            wp_cache_set('bp_user_fullname_' . $user_id, $fullname, 'bp');
        }
    }
    return apply_filters('bp_core_get_user_displayname', $fullname, $user_id);
}
 public static function get_fullname($user_id = 0)
 {
     if (empty($user_id)) {
         $user_id = bp_displayed_user_id();
     }
     $data = xprofile_get_field_data(bp_xprofile_fullname_field_id(), $user_id);
     return $data[$field_name];
 }
 /**
  * @group bp_core_get_user_displayname
  */
 public function test_bp_core_get_user_displayname_xprofile_does_not_exist()
 {
     $bp = buddypress();
     $xprofile_is_active = bp_is_active('xprofile');
     $bp->active_components['xprofile'] = '1';
     $u = $this->factory->user->create(array('display_name' => 'Foo Foo'));
     // Delete directly because BP won't let you delete a required
     // field through the API
     global $wpdb;
     $wpdb->query($wpdb->prepare("DELETE FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = 1", $u));
     wp_cache_delete('bp_user_fullname_' . $u, 'bp');
     wp_cache_delete("{$u}:1", 'bp_xprofile_data');
     $this->assertSame('', xprofile_get_field_data(1, $u));
     $this->assertSame('Foo Foo', bp_core_get_user_displayname($u));
     $this->assertSame('Foo Foo', xprofile_get_field_data(1, $u));
     if (!$xprofile_is_active) {
         unset($bp->active_components['xprofile']);
     }
 }
/**
 * Syncs Xprofile data to the standard built in WordPress profile data.
 *
 * @since 1.0.0
 *
 * @param int $user_id ID of the user to sync.
 * @return bool
 */
function xprofile_sync_wp_profile($user_id = 0)
{
    // Bail if profile syncing is disabled.
    if (bp_disable_profile_sync()) {
        return true;
    }
    if (empty($user_id)) {
        $user_id = bp_loggedin_user_id();
    }
    if (empty($user_id)) {
        return false;
    }
    $fullname = xprofile_get_field_data(bp_xprofile_fullname_field_id(), $user_id);
    $space = strpos($fullname, ' ');
    if (false === $space) {
        $firstname = $fullname;
        $lastname = '';
    } else {
        $firstname = substr($fullname, 0, $space);
        $lastname = trim(substr($fullname, $space, strlen($fullname)));
    }
    bp_update_user_meta($user_id, 'nickname', $fullname);
    bp_update_user_meta($user_id, 'first_name', $firstname);
    bp_update_user_meta($user_id, 'last_name', $lastname);
    wp_update_user(array('ID' => $user_id, 'display_name' => $fullname));
    wp_cache_delete('bp_core_userdata_' . $user_id, 'bp');
}
/**
 * Syncs Xprofile data to the standard built in NXTClass profile data.
 *
 * @package BuddyPress Core
 */
function xprofile_sync_nxt_profile($user_id = 0)
{
    global $bp, $nxtdb;
    if (!empty($bp->site_options['bp-disable-profile-sync']) && (int) $bp->site_options['bp-disable-profile-sync']) {
        return true;
    }
    if (empty($user_id)) {
        $user_id = $bp->loggedin_user->id;
    }
    if (empty($user_id)) {
        return false;
    }
    $fullname = xprofile_get_field_data(bp_xprofile_fullname_field_name(), $user_id);
    $space = strpos($fullname, ' ');
    if (false === $space) {
        $firstname = $fullname;
        $lastname = '';
    } else {
        $firstname = substr($fullname, 0, $space);
        $lastname = trim(substr($fullname, $space, strlen($fullname)));
    }
    update_user_meta($user_id, 'nickname', $fullname);
    update_user_meta($user_id, 'first_name', $firstname);
    update_user_meta($user_id, 'last_name', $lastname);
    $nxtdb->query($nxtdb->prepare("UPDATE {$nxtdb->users} SET display_name = %s WHERE ID = %d", $fullname, $user_id));
}
/**
 * Return XProfile field data.
 *
 * @since 1.2.0
 *
 * @param string|array $args {
 *    Array of arguments for field data.
 *
 *    @type string|int|bool $field   Field identifier.
 *    @type int             $user_id ID of the user to get field data for.
 * }
 * @return mixed|void
 */
function bp_get_profile_field_data($args = '')
{
    $r = wp_parse_args($args, array('field' => false, 'user_id' => bp_displayed_user_id()));
    /**
     * Filters the profile field data.
     *
     * @since 1.2.0
     * @since 2.6.0 Added the `$r` parameter.
     *
     * @param mixed $value Profile data for a specific field for the user.
     * @param array $r     Array of parsed arguments.
     */
    return apply_filters('bp_get_profile_field_data', xprofile_get_field_data($r['field'], $r['user_id']), $r);
}
 /**
  * has_student_caps( $user_id )
  *
  * Checks if $user_id has response management capabilities
  *
  * @param Int $user_id ID of the user capabilities to be checked, default null
  * @return True if $user_id is eligible and False if not.
  */
 function has_student_caps($user_id = null)
 {
     global $bp;
     if (!$user_id) {
         $user_id = $bp->loggedin_user->id;
     }
     $user_role = xprofile_get_field_data(__('Role'), $user_id);
     // Go away teacher
     if (__('Student', 'bpsp') != $user_role && !empty($user_role)) {
         return false;
     }
     // Treat super admins
     if (is_super_admin($user_id)) {
         $this->add_response_caps($user_id);
     }
     $user = new WP_User($user_id);
     foreach ($this->students_caps as $c) {
         if (!$user->has_cap($c)) {
             $user->add_cap($c);
         }
     }
     return true;
 }
function rw_boss_social_header()
{
    ?>
	<div class="btn-group social">
    <?php 
    foreach (rw_boss_get_user_social_array() as $social => $arr) {
        $url = xprofile_get_field_data($social, bp_displayed_user_id(), 'comma');
        $ico = empty($arr['icon-url']) ? '<i class="alt-social-icon alt-' . $social . '"></i>' : '<img class="user-social-icons-btn" src="' . $arr['icon-url'] . '">';
        if (!empty($url)) {
            ?>
			<a class="btn" href="<?php 
            echo $url;
            ?>
" title="<?php 
            echo esc_attr($arr['title']);
            ?>
"><?php 
            echo $ico;
            ?>
</a>
		<?php 
        }
        ?>
	<?php 
    }
    ?>
	</div>
	<?php 
}
Beispiel #16
0
 /**
  * Handles BP profile saving action
  *
  * @global object $current_user
  * @param int $user_id
  * @param array $posted_field_ids
  * @param array $errors
  * @author korotkov@UD
  */
 static function bp_profile_updated($user_id, $posted_field_ids, $errors)
 {
     global $current_user, $bp;
     if (is_admin()) {
         return;
     }
     //** Get new user_data from POST */
     $user_data = $_REQUEST['wp_crm']['user_data'];
     //** user_id is required */
     $user_data['user_id'][0]['value'] = $user_id;
     //** user_email is required */
     if (!array_key_exists('user_email', $user_data)) {
         $user_data['user_email'][0]['value'] = $current_user->user_email;
     }
     //** Change display name if xprofile full name exists */
     $fullname_field_name = bp_xprofile_fullname_field_name();
     $fullname_field_id = xprofile_get_field_id_from_name($fullname_field_name);
     if (in_array($fullname_field_id, $posted_field_ids)) {
         $display_name = xprofile_get_field_data($fullname_field_name, $user_id);
         $user_data['display_name'] = $display_name;
     }
     //** Save user data */
     $user_id = wp_crm_save_user_data($user_data);
     //** Determine if user changed nicename (display name in URL). peshkov@UD */
     if ($user_id && isset($user_data['user_nicename'])) {
         $user_domain = bp_displayed_user_domain();
         $userdata = get_userdata($user_id);
         $user_nicename = $userdata->data->user_nicename;
         $needle = bp_get_members_root_slug() . '/' . $user_nicename . '/';
         $pos = strpos($user_domain, $needle);
         if ($pos === false) {
             //** Looks like user_nicename was changed so redirect to the new profile's URL. */
             $user_domain = str_replace($bp->displayed_user->userdata->user_nicename, $user_nicename, $user_domain);
             if ($errors) {
                 bp_core_add_message(__('There was a problem updating some of your profile information, please try again.', ud_get_wp_crm()->domain), 'error');
             } else {
                 bp_core_add_message(__('Changes saved.', ud_get_wp_crm()->domain));
             }
             //* Redirect back to the edit screen to display the updates and message */
             bp_core_redirect(trailingslashit($user_domain . $bp->profile->slug . '/edit/group/' . bp_action_variable(1)));
         }
     }
 }
Beispiel #17
0
 function add_bulk_students()
 {
     $course_id = $_POST['course'];
     if (!isset($_POST['security']) || !wp_verify_nonce($_POST['security'], 'security' . $course_id)) {
         echo 'Security check failed !';
         die;
     }
     $members = $_POST['members'];
     $member_ids = array();
     if (!is_Array($members)) {
         $members = stripslashes($members);
         if (strpos($members, ',')) {
             $members = explode(',', $members);
         } else {
             $members = array($members);
         }
     }
     $html = '';
     foreach ($members as $member) {
         if (is_numeric($member)) {
             $user_id = $member;
         } else {
             if (filter_var($member, FILTER_VALIDATE_EMAIL)) {
                 $user_id = email_exists($member);
             } else {
                 $user_id = bp_core_get_userid_from_nicename($member);
             }
         }
         if (!empty($user_id)) {
             $force_flag = apply_filters('wplms_force_flag_bulk_add_students', 1, $course_id, $user_id);
             $check = bp_course_add_user_to_course($user_id, $course_id, '', $force_flag);
             if ($check) {
                 $field = vibe_get_option('student_field');
                 if (!isset($field) || !$field) {
                     $field = 'Location';
                 }
                 $html .= '<li id="s' . $user_id . '">
             <input type="checkbox" class="member" value="' . $user_id . '">
             ' . bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'full')) . '
             <h6>' . bp_core_get_userlink($user_id) . '</h6><span>' . (function_exists('xprofile_get_field_data') ? xprofile_get_field_data($field, $user_id) : '') . '</span><ul> 
             <li><a class="tip reset_course_user" data-course="' . $course_id . '" data-user="******" title="" data-original-title="' . __('Reset Course for User', 'vibe') . '"><i class="icon-reload"></i></a></li>
             <li><a class="tip course_stats_user" data-course="' . $course_id . '" data-user="******" title="" data-original-title="' . __('See Course stats for User', 'vibe') . '"><i class="icon-bars"></i></a></li>
             <li><a class="tip remove_user_course" data-course="' . $course_id . '" data-user="******" title="" data-original-title="' . __('Remove User from this Course', 'vibe') . '"><i class="icon-x"></i></a></li>
             </ul></li>';
                 $member_ids[] = $user_id;
             }
         }
     }
     echo $html;
     if (!empty($member_ids)) {
         foreach ($member_ids as $member_id) {
             do_action('wplms_course_subscribed', $course_id, $user_id);
         }
         do_action('wplms_bulk_action', 'added_students', $course_id, $member_ids);
     }
     die;
 }
function td_bpxps_xprofile_shortcode($attributes)
{
    global $wpdb;
    if (empty($attributes['field'])) {
        return false;
    }
    extract($attributes);
    $urlWithOutSlash = 'http://' . $_SERVER['HTTP_HOST'];
    $thisUserId = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->users} WHERE user_url = %s LIMIT 1", $urlWithOutSlash));
    // $user_id = (isset($user)) ? $user : false;
    $user_id = $thisUserId;
    global $bp;
    if (!empty($user_id) && intval($user_id) === 0) {
        // shortcode-defined username
        $user_id = get_user_id_from_string(get_blog_option($thisblog, 'admin_email'));
    }
    if (isset($user) && $user == 'displayed' || empty($user_id) && isset($bp->displayed_user->id)) {
        // On profile page, show the displayed user's information
        $user_id = $bp->displayed_user->id;
    }
    global $post;
    if (isset($user) && $user == 'author' || empty($user_id) && !empty($post->post_author)) {
        // On author or single post page, show the author's information
        $user_id = $post->post_author;
    }
    if (isset($user) && $user == 'current' || empty($user_id) && is_user_logged_in()) {
        // Show the currently logged in user's information
        $user_id = get_current_user_id();
    }
    if (empty($user_id)) {
        return false;
    }
    return xprofile_get_field_data($field, $user_id);
}
                 break;
         }
     }
 }
 // Processing users count by gender and age groups
 $users = get_users_by_date($date, $lesson_id);
 foreach ($users as $user) {
     $gender = xprofile_get_field_data('gender', $user['user_id']);
     if ($gender == "male" || $gender == "муж") {
         $days[$date->format('Y-m-d')]['male']++;
     } else {
         if ($gender == "female" || $gender == "жен" || $gender == "женский" || $gender == "F") {
             $days[$date->format('Y-m-d')]['female']++;
         }
     }
     $age = xprofile_get_field_data('age', $user['user_id']);
     if ($age >= 18 && $age <= 24) {
         $days[$date->format('Y-m-d')]['18-24']++;
     } elseif ($age >= 25 && $age <= 34) {
         $days[$date->format('Y-m-d')]['25-34']++;
     } elseif ($age >= 35 && $age <= 44) {
         $days[$date->format('Y-m-d')]['35-44']++;
     } elseif ($age >= 45 && $age <= 54) {
         $days[$date->format('Y-m-d')]['45-54']++;
     } elseif ($age >= 55) {
         $days[$date->format('Y-m-d')]['55plus']++;
     }
 }
 $total_forum += $days[$date->format('Y-m-d')]['forum'];
 $total_archive += $days[$date->format('Y-m-d')]['archive'];
 $total_webinarTT += $days[$date->format('Y-m-d')]['webinarTT'];
 public static function getUserFieldList($user_id = 0)
 {
     $user_id = $user_id == 0 ? get_current_user_id() : $user_id;
     $fieldList = array('first_name' => array('val' => '', 'type' => 'wp', 'translate' => __('Your First Name', 'cfef')), 'last_name' => array('val' => '', 'type' => 'wp', 'translate' => __('Last Name', 'cfef')), 'display_name' => array('val' => '', 'type' => 'wp', 'translate' => __('Display Name', 'cfef')), 'user_email' => array('val' => '', 'type' => 'wp', 'translate' => __('Email', 'cfef')));
     foreach (get_option('mailChimpFieldList') as $key => $val) {
         $fieldVal = $user_id == -1 ? "" : xprofile_get_field_data($val, $user_id);
         $fieldList[$val] = array('val' => $fieldVal, 'type' => 'bp', 'translate' => __($val, 'cfef'));
     }
     if ($user_id == -1) {
         return $fieldList;
     }
     $currentUser = get_user_by("id", $user_id);
     $fieldList['last_name']['val'] = get_userdata($user_id)->last_name;
     $fieldList['first_name']['val'] = get_userdata($user_id)->first_name;
     $fieldList['display_name']['val'] = $currentUser->data->display_name;
     $fieldList['user_email']['val'] = $currentUser->data->user_email;
     return $fieldList;
 }
Beispiel #21
0
</h6>

						<?php 
        do_action('wplms_certificate_before_name');
        ?>

						<h2><?php 
        echo bp_core_get_user_displayname($user_id);
        ?>

							<?php 
        do_action('wplms_certificate_after_name');
        ?>

							<span><?php 
        echo xprofile_get_field_data('Location', $user_id);
        ?>
</span></h2>

						<span><?php 
        echo apply_filters('wplms_certificate_before_course_title', __('for successful completion of course', 'vibe'));
        ?>
</span>
						<h3><?php 
        echo get_the_title($course_id);
        ?>
</h3>
						<?php 
        do_action('wplms_certificate_after_content');
        ?>
					</div>
  <div class="author">

    <?php 
do_action('bbp_theme_before_reply_author_details');
$args = ['sep' => '', 'show_role' => true, 'type' => 'avatar'];
bbp_reply_author_link($args);
?>

  </div>

  <div class="content">
    <div class="replyheader">
      <div id="country" style="float:left;margin-right:.5em;"> <?php 
$user = get_userdata(bbp_get_reply_author_id());
$country = xprofile_get_field_data(42, $user->ID);
dh_get_flag_by_location($country);
?>
</div>

      <div class="smallusername">

        <?php 
if (!empty($user->user_nicename)) {
    $user_nicename = $user->user_nicename;
    echo "" . $user_nicename;
}
?>


      </div>
Beispiel #23
0
 public static function handle_existing_images_submission($form)
 {
     global $_gf_uploaded_files;
     // get UR config
     // get all fileupload fields mapped in the UR config
     // foreach loop through and see if the image has been:
     //  - resubmitted           populate the existing image data into the $_gf_uploaded_files
     //  - deleted               do nothing
     //  - new image submitted   do nothing
     if (empty($_gf_uploaded_files)) {
         $_gf_uploaded_files = array();
     }
     $config = GFUserData::get_update_feed($form['id']);
     if (!$config) {
         return;
     }
     $meta = rgars($config, 'meta/user_meta');
     if (function_exists('xprofile_get_field_data')) {
         $bp_meta = rgars($config, 'meta/buddypress_meta');
         if (is_array($bp_meta)) {
             $bp_meta = array_map(create_function('$a', '$a["is_bp"] = true; return $a;'), $bp_meta);
             $meta = array_merge($meta, $bp_meta);
         }
     }
     foreach ($meta as $meta_item) {
         $field = RGFormsModel::get_field($form, $meta_item['meta_value']);
         $input_name = "input_{$field['id']}";
         if (RGFormsModel::get_input_type($field) != 'fileupload') {
             continue;
         }
         if (self::is_prepopulated_file_upload($form['id'], $input_name)) {
             if (rgar($meta_item, 'is_bp')) {
                 $_gf_uploaded_files[$input_name] = xprofile_get_field_data($meta_item['meta_name'], get_current_user_id());
             } else {
                 $_gf_uploaded_files[$input_name] = get_user_meta(get_current_user_id(), $meta_item['meta_name'], true);
             }
         }
     }
 }
Beispiel #24
0
	function get_fullname( $user_id = false ) {
		global $bp;

		if ( !$user_id )
			$user_id = $bp->displayed_user->id;

		$data = xprofile_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id );

		return $data[BP_XPROFILE_FULLNAME_FIELD_NAME];
	}
function bp_fetch_user_fullname($user_id, $echo = true)
{
    global $bp;
    if (!$user_id) {
        return false;
    }
    if (!($fullname = wp_cache_get('bp_user_fullname_' . $user_id, 'bp'))) {
        if (function_exists('xprofile_install')) {
            $fullname = xprofile_get_field_data(BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id);
            if (empty($fullname) || !$fullname) {
                $ud = get_userdata($user_id);
                $fullname = $ud->display_name;
                xprofile_set_field_data(BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id, $fullname);
            }
        } else {
            $ud = get_userdata($user_id);
            $fullname = $ud->display_name;
        }
        wp_cache_set('bp_user_fullname_' . $user_id, $fullname, 'bp');
    }
    if ($echo) {
        echo apply_filters('bp_fetch_user_fullname', stripslashes(trim($fullname)));
    } else {
        return apply_filters('bp_fetch_user_fullname', stripslashes(trim($fullname)));
    }
}
    function lms_commission_payments()
    {
        echo '<h3>' . __('Pay Instructor Commisions', 'vibe-customtypes') . '</h3>';
        if (isset($_POST['set_time'])) {
            $start_date = $_POST['start_date'];
            $end_date = $_POST['end_date'];
        }
        if (isset($_POST['payment_complete'])) {
            $post = array();
            $post['post_title'] = sprintf(__('Commission Payments on %s', 'vibe-customtypes'), date('Y-m-d H:i:s'));
            $post['post_status'] = 'publish';
            $post['post_type'] = 'payments';
            $post_id = wp_insert_post($post, $wp_error);
            if (isset($post_id) && $post_id) {
                update_post_meta($post_id, 'vibe_instructor_commissions', $_POST['instructor']);
                update_post_meta($post_id, 'vibe_date_from', $_POST['start_date']);
                update_post_meta($post_id, 'vibe_date_to', $_POST['end_date']);
                echo '<div id="moderated" class="updated below-h2"><p>' . __(' Commission Payments Saved', 'vibe-customtypes') . '</p></div>';
            } else {
                echo '<div id="moderated" class="error below-h2"><p>' . __('Commission payments not saved !', 'vibe-customtypes') . '</p></div>';
            }
        }
        echo '<form method="POST" name="payment">';
        $posts = get_posts(array('post_type' => 'payments', 'orderby' => 'date', 'order' => 'DESC', 'numberposts' => '1'));
        foreach ($posts as $post) {
            $date = $post->post_date;
            $id = $post->ID;
        }
        if (isset($date)) {
            echo '<strong>LAST PAYMENT : ' . date("G:i | D , M j Y", strtotime($date)) . '</strong> <a href="' . get_edit_post_link($id) . '" class="small_link">' . __('CHECK NOW', 'vibe-customtypes') . '</a><br /><br />';
        }
        if (!isset($start_date)) {
            $start_date = date('Y-m-d', strtotime(date('Ym', current_time('timestamp')) . '01'));
        }
        if (!isset($end_date)) {
            $end_date = date('Y-m-d', current_time('timestamp'));
        }
        echo '<strong>' . __('SET TIME PERIOD', 'vibe-customtypes') . ' :</strong><input type="text" name="start_date" id="from" value="' . $start_date . '" class="date-picker-field">
					 <label for="to">&nbsp;&nbsp; To:</label> 
					<input type="text" name="end_date" id="to" value="' . $end_date . '" class="date-picker-field">
					<input type="submit" class="button" name="set_time" value="Show"></p>';
        if (isset($_POST['set_time'])) {
            echo '<div class="postbox instructor_info">
						<h3><label>' . __('Instructor Name', 'vibe-customtypes') . '</label><span>' . __('Commission', 'vibe-customtypes') . ' (' . get_woocommerce_currency_symbol() . ')</span><span>' . __('PAYPAL EMAIL', 'vibe-customtypes') . '</span><span>' . __('Select', 'vibe-customtypes') . '</span><span>' . __('Pay via PayPal', 'vibe-customtypes') . '</span></h3>
						<div class="inside">
							<ul>';
            $order_data = new WPLMS_Commissions();
            $instructor_data = $order_data->instructor_data($start_date, $end_date);
            $instructors = get_users('role=instructor');
            foreach ($instructors as $instructor) {
                $instructor_email = $instructor->user_email;
                if (function_exists('xprofile_get_field_data')) {
                    $field = vibe_get_option('instructor_paypal_field');
                    if (xprofile_get_field_data($field, $instructor->ID)) {
                        $instructor_email = xprofile_get_field_data($field, $instructor->ID);
                    }
                }
                echo '<li><label>' . $instructor->user_nicename . '</label>
						        <span><input type="number" id="' . $instructor->user_login . '_amount" name="instructor[' . $instructor->ID . '][commission]" class="text" value="' . (isset($instructor_data[$instructor->ID]) ? $instructor_data[$instructor->ID] : 0) . '" /></span>
						        <span><input type="text" id="' . $instructor->user_login . '_email" name="instructor[' . $instructor->ID . '][email]"  value="' . $instructor_email . '" /></span>
						        <span><input type="checkbox" name="instructor[' . $instructor->ID . '][set]" class="checkbox" value="1" /></span>
						        <span>
						        <a id="' . $instructor->user_login . '_payment" class="button">' . __('Pay via PayPal', 'vibe-customtypes') . '</a>
						        
						        </span>
						        <script>
						        	jQuery(document).ready(function($){
						        		$("#' . $instructor->user_login . '_payment").click(function(){
						        			var amount =$("#' . $instructor->user_login . '_amount").val();
						        			var email =$("#' . $instructor->user_login . '_email").val();
						        			$(\'<form name="_xclick" action="https://www.paypal.com/in/cgi-bin/webscr" method="post" target="_blank"><input type="hidden" name="cmd" value="_xclick"><input type="hidden" name="business" value="\'+email+\'"><input type="hidden" name="currency_code" value="' . get_woocommerce_currency() . '"><input type="hidden" name="item_name" value="' . __('Instructor Commission', 'vibe-customtypes') . '"><input type="hidden" name="amount" value="\'+amount+\'"></form>\').appendTo($(this)).submit();
						        		});
						        	});
						        </script>
						        </li>';
            }
            echo '</ul>
						</div>
					</div>
					<input type="submit" class="button-primary" name="payment_complete" value="' . __('Mark as Paid', 'vibe-customtypes') . '">
			   ';
        }
        echo '</form>';
    }
/**
 * Syncs Xprofile data to the standard built in WordPress profile data.
 *
 * @package BuddyPress Core
 */
function xprofile_sync_wp_profile($user_id = 0)
{
    // Bail if profile syncing is disabled
    if (bp_disable_profile_sync()) {
        return true;
    }
    if (empty($user_id)) {
        $user_id = bp_loggedin_user_id();
    }
    if (empty($user_id)) {
        return false;
    }
    $fullname = xprofile_get_field_data(bp_xprofile_fullname_field_id(), $user_id);
    $space = strpos($fullname, ' ');
    if (false === $space) {
        $firstname = $fullname;
        $lastname = '';
    } else {
        $firstname = substr($fullname, 0, $space);
        $lastname = trim(substr($fullname, $space, strlen($fullname)));
    }
    bp_update_user_meta($user_id, 'nickname', $fullname);
    bp_update_user_meta($user_id, 'first_name', $firstname);
    bp_update_user_meta($user_id, 'last_name', $lastname);
    global $wpdb;
    $wpdb->query($wpdb->prepare("UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $user_id));
}
function bp_get_profile_field_data($args = '')
{
    global $bp;
    $defaults = array('field' => false, 'user_id' => bp_displayed_user_id());
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    return apply_filters('bp_get_profile_field_data', xprofile_get_field_data($field, $user_id));
}
Beispiel #29
0
 public function xprofile()
 {
     global $json_api;
     if (function_exists('bp_is_active')) {
         if (!$json_api->query->user_id) {
             $json_api->error("You must include a 'user_id' var in your request.");
         } else {
             $user_id = $json_api->query->user_id;
         }
         if (!$json_api->query->field) {
             $json_api->error("You must include a 'field' var in your request. Use 'field=default' for all default fields.");
         } elseif ($json_api->query->field == 'default') {
             $field_label = 'First Name, Last Name, Bio';
             /*you should add your own field labels here for quick viewing*/
         } else {
             $field_label = sanitize_text_field($json_api->query->field);
         }
         $fields = explode(",", $field_label);
         if (is_array($fields)) {
             foreach ($fields as $k) {
                 $fields_data[$k] = xprofile_get_field_data($k, $user_id);
             }
             return $fields_data;
         }
     } else {
         $json_api->error("You must install and activate BuddyPress plugin to use this method.");
     }
 }
 /**
  * is_teacher( $user_id )
  *
  * Checks if $user_id is a teacher
  * @param Int $user_id, user ID to check for
  * @return Bool, true if is a teacher and false on failure
  */
 function is_teacher($user_id)
 {
     if (__('Teacher', 'bpsp') == xprofile_get_field_data(__('Role', 'bpsp'), $user_id)) {
         return true;
     } else {
         return false;
     }
 }