Skip to:
Content

BuddyPress.org

Changeset 1681


Ignore:
Timestamp:
08/22/2009 07:21:36 PM (16 years ago)
Author:
apeatling
Message:

Re-added stripslashes filter to xprofile edit values and moved syncing function from filters file.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile.php

    r1672 r1681  
    979979}
    980980
     981/**
     982 * xprofile_avatar_upload_dir()
     983 *
     984 * Setup the avatar upload directory for a user.
     985 *
     986 * @package BuddyPress Core
     987 * @param $directory The root directory name
     988 * @param $user_id The user ID.
     989 * @return array() containing the path and URL plus some other settings.
     990 */
    981991function xprofile_avatar_upload_dir( $directory = false, $user_id = false ) {
    982992    global $bp;
     
    984994    if ( !$user_id )
    985995        $user_id = $bp->displayed_user->id;
     996   
     997    if ( !$directory )
     998        $directory = 'avatars';
    986999
    9871000    $path  = get_blog_option( BP_ROOT_BLOG, 'upload_path' );
     
    9941007        @wp_mkdir_p( $newdir );
    9951008
    996     $newurl = WP_CONTENT_URL . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/' . $user_id;
     1009    $newurl = WP_CONTENT_URL . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $directory . '/' . $user_id;
    9971010    $newburl = $newurl;
    9981011    $newsubdir = '/avatars/' . $user_id;
     
    10001013    return apply_filters( 'xprofile_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
    10011014}
     1015
     1016/**
     1017 * xprofile_sync_wp_profile()
     1018 *
     1019 * Syncs Xprofile data to the standard built in WordPress profile data.
     1020 *
     1021 * @package BuddyPress Core
     1022 */
     1023function xprofile_sync_wp_profile() {
     1024    global $bp, $wpdb;
     1025   
     1026    if ( (int)get_site_option( 'bp-disable-profile-sync' ) )
     1027        return true;
     1028   
     1029    $fullname = xprofile_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $bp->loggedin_user->id );
     1030    $space = strpos( $fullname, ' ' );
     1031   
     1032    if ( false === $space ) {
     1033        $firstname = $fullname;
     1034        $lastname = '';
     1035    } else {
     1036        $firstname = substr( $fullname, 0, $space );
     1037        $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );     
     1038    }
     1039   
     1040    update_usermeta( $bp->loggedin_user->id, 'nickname', $fullname );
     1041    update_usermeta( $bp->loggedin_user->id, 'first_name', $firstname );
     1042    update_usermeta( $bp->loggedin_user->id, 'last_name', $lastname );
     1043
     1044    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $bp->loggedin_user->id ) );
     1045    $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 ) );
     1046}
     1047add_action( 'xprofile_updated_profile', 'xprofile_sync_wp_profile' );
    10021048
    10031049
  • trunk/bp-xprofile/bp-xprofile-filters.php

    r1636 r1681  
    1818add_filter( 'bp_get_the_profile_field_value', 'wpautop' );
    1919add_filter( 'bp_get_the_profile_field_value', 'make_clickable' );
     20
    2021add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_format_field_value', 1, 2 );
    2122add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 2, 2 );
     23
     24add_filter( 'bp_get_the_profile_field_edit_value', 'stripslashes' );
    2225
    2326/* Custom BuddyPress filters */
     
    6669}
    6770
    68 function xprofile_sync_wp_profile() {
    69     global $bp, $wpdb;
    70    
    71     if ( (int)get_site_option( 'bp-disable-profile-sync' ) )
    72         return true;
    73    
    74     $fullname = xprofile_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $bp->loggedin_user->id );
    75     $space = strpos( $fullname, ' ' );
    76    
    77     if ( false === $space ) {
    78         $firstname = $fullname;
    79         $lastname = '';
    80     } else {
    81         $firstname = substr( $fullname, 0, $space );
    82         $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );     
    83     }
    84    
    85     update_usermeta( $bp->loggedin_user->id, 'nickname', $fullname );
    86     update_usermeta( $bp->loggedin_user->id, 'first_name', $firstname );
    87     update_usermeta( $bp->loggedin_user->id, 'last_name', $lastname );
    88 
    89     $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $bp->loggedin_user->id ) );
    90     $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 ) );
    91 }
    92 add_action( 'xprofile_updated_profile', 'xprofile_sync_wp_profile' );
    93 
    9471
    9572?>
Note: See TracChangeset for help on using the changeset viewer.