Changeset 2758 for branches/plugin/bbp-includes/bbp-user-template.php
- Timestamp:
- 01/06/2011 08:25:58 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-user-template.php
r2734 r2758 1 1 <?php 2 2 3 /** 4 * bbPress User Functions 5 * 6 * @package bbPress 7 * @subpackage TemplateTags 8 */ 9 3 10 /** START User Functions ******************************************************/ 4 11 5 12 /** 6 * bbp_user_id () 7 * 8 * Output a validated user_id 9 * 10 * @param int $user_id 11 * @param bool $current_user_fallback 12 */ 13 function bbp_user_id ( $user_id = 0, $displayed_user_fallback = true, $current_user_fallback = false ) { 13 * Output a validated user id 14 * 15 * @since bbPress (r2729) 16 * 17 * @param int $user_id Optional. User id 18 * @param bool $displayed_user_fallback Fallback on displayed user? 19 * @param bool $current_user_fallback Fallback on current user? 20 * @uses bbp_get_user_id() To get the user id 21 */ 22 function bbp_user_id( $user_id = 0, $displayed_user_fallback = true, $current_user_fallback = false ) { 14 23 echo bbp_get_user_id( $user_id, $displayed_user_fallback, $current_user_fallback ); 15 24 } 16 25 /** 17 * bbp_get_user_id () 18 * 19 * Return a validated user_id 20 * 21 * @global bbPress $bbp 22 * @param int $user_id 23 * @param bool $displayed_user_fallback 24 * @param bool $current_user_fallback 25 * @return int 26 */ 27 function bbp_get_user_id ( $user_id = 0, $displayed_user_fallback = true, $current_user_fallback = false ) { 26 * Return a validated user id 27 * 28 * @since bbPress (r2729) 29 * 30 * @param int $user_id Optional. User id 31 * @param bool $displayed_user_fallback Fallback on displayed user? 32 * @param bool $current_user_fallback Fallback on current user? 33 * @uses get_query_var() To get the 'bbp_user_id' query var 34 * @uses apply_filters() Calls 'bbp_get_user_id' with the user id 35 * @return int Validated user id 36 */ 37 function bbp_get_user_id( $user_id = 0, $displayed_user_fallback = true, $current_user_fallback = false ) { 28 38 global $bbp; 29 39 … … 31 41 if ( !empty( $user_id ) && is_numeric( $user_id ) ) 32 42 $bbp_user_id = $user_id; 33 43 34 44 // Currently viewing or editing a user 35 45 elseif ( ( true == $displayed_user_fallback ) && !empty( $bbp->displayed_user->ID ) && isset( $bbp->displayed_user->ID ) ) … … 50 60 51 61 /** 52 * bbp_favorites_permalink ()53 *54 62 * Output the link to the user's favorites page (profile page) 55 63 * 56 * @package bbPress57 * @subpackage Template Tags58 64 * @since bbPress (r2652) 59 65 * 60 * @param int $user_id optional61 * @uses bbp_get_favorites_permalink() 62 */ 63 function bbp_favorites_permalink ( $user_id = 0 ) {66 * @param int $user_id Optional. User id 67 * @uses bbp_get_favorites_permalink() To get the favorites permalink 68 */ 69 function bbp_favorites_permalink( $user_id = 0 ) { 64 70 echo bbp_get_favorites_permalink( $user_id ); 65 71 } 66 72 /** 67 * bbp_get_favorites_permalink ()68 *69 73 * Return the link to the user's favorites page (profile page) 70 74 * 71 * @package bbPress72 * @subpackage Template Tags73 75 * @since bbPress (r2652) 74 76 * 75 * @param int $user_id optional 76 * @uses apply_filters 77 * @uses bbp_get_user_profile_url 77 * @param int $user_id Optional. User id 78 * @uses bbp_get_user_profile_url() To get the user profile url 79 * @uses apply_filters() Calls 'bbp_get_favorites_permalink' with the 80 * user profile url and user id 78 81 * @return string Permanent link to user profile page 79 82 */ 80 function bbp_get_favorites_permalink ( $user_id = 0 ) { 81 return apply_filters( 'bbp_get_favorites_permalink', bbp_get_user_profile_url( $user_id ) ); 82 } 83 84 /** 85 * bbp_user_favorites_link () 86 * 83 function bbp_get_favorites_permalink( $user_id = 0 ) { 84 return apply_filters( 'bbp_get_favorites_permalink', bbp_get_user_profile_url( $user_id ), $user_id ); 85 } 86 87 /** 87 88 * Output the link to make a topic favorite/remove a topic from favorites 88 89 * 89 * @package bbPress90 * @subpackage Template Tags91 90 * @since bbPress (r2652) 92 91 * 93 * @param array $add optional 94 * @param array $rem optional 95 * @param int $user_id optional 96 * 97 * @uses bbp_get_user_favorites_link() 98 */ 99 function bbp_user_favorites_link ( $add = array(), $rem = array(), $user_id = 0 ) { 92 * @param array $add Optional. Add to favorites args 93 * @param array $rem Optional. Remove from favorites args 94 * @param int $user_id Optional. User id 95 * @uses bbp_get_user_favorites_link() To get the user favorites link 96 */ 97 function bbp_user_favorites_link( $add = array(), $rem = array(), $user_id = 0 ) { 100 98 echo bbp_get_user_favorites_link( $add, $rem, $user_id ); 101 99 } 102 100 /** 103 * bbp_get_user_favorites_link () 104 * 105 * Return the link to make a topic favorite/remove a topic from favorites 106 * 107 * @package bbPress 108 * @subpackage Template Tags 101 * User favorites link 102 * 103 * Return the link to make a topic favorite/remove a topic from 104 * favorites 105 * 109 106 * @since bbPress (r2652) 110 107 * 111 * @param array $add optional 112 * @param array $rem optional 113 * @param int $user_id optional 114 * 115 * @uses apply_filters 116 * @return string Permanent link to topic 117 */ 118 function bbp_get_user_favorites_link ( $add = array(), $rem = array(), $user_id = 0 ) { 108 * @param array $add Optional. Add to favorites args 109 * @param array $rem Optional. Remove from favorites args 110 * @param int $user_id Optional. User id 111 * @uses bbp_get_user_id() To get the user id 112 * @uses current_user_can() If the current user can edit the user 113 * @uses bbp_get_topic_id() To get the topic id 114 * @uses bbp_is_user_favorite() To check if the topic is user's favorite 115 * @uses bbp_get_favorites_permalink() To get the favorites permalink 116 * @uses bbp_get_topic_permalink() To get the topic permalink 117 * @uses bbp_is_favorites() Is it the favorites page? 118 * @uses apply_filters() Calls 'bbp_get_user_favorites_link' with the 119 * html, add args, remove args, user & topic id 120 * @return string User favorites link 121 */ 122 function bbp_get_user_favorites_link( $add = array(), $rem = array(), $user_id = 0 ) { 119 123 global $bbp; 120 124 … … 174 178 175 179 /** 176 * bbp_subscriptions_permalink ()177 *178 180 * Output the link to the user's subscriptions page (profile page) 179 181 * 180 * @package bbPress 181 * @subpackage Template Tags 182 * @since bbPress (r2688) 183 * 184 * @param int $user_id optional 185 * @uses bbp_get_subscriptions_permalink() 186 */ 187 function bbp_subscriptions_permalink ( $user_id = 0 ) { 182 * @since bbPress (r2688) 183 * 184 * @param int $user_id Optional. User id 185 * @uses bbp_get_subscriptions_permalink() To get the subscriptions link 186 */ 187 function bbp_subscriptions_permalink( $user_id = 0 ) { 188 188 echo bbp_get_subscriptions_permalink( $user_id ); 189 189 } 190 190 /** 191 * bbp_get_subscriptions_permalink ()192 *193 191 * Return the link to the user's subscriptions page (profile page) 194 192 * 195 * @package bbPress196 * @subpackage Template Tags197 193 * @since bbPress (r2688) 198 194 * 199 * @param int $user_id optional 200 * @uses apply_filters 201 * @uses bbp_get_user_profile_url 202 * @return string Permanent link to user profile page 203 */ 204 function bbp_get_subscriptions_permalink ( $user_id = 0 ) { 205 return apply_filters( 'bbp_get_favorites_permalink', bbp_get_user_profile_url( $user_id ) ); 206 } 207 208 /** 209 * bbp_user_subscribe_link () 210 * 195 * @param int $user_id Optional. User id 196 * @uses bbp_get_user_profile_url() To get the user profile url 197 * @uses apply_filters() Calls 'bbp_get_favorites_permalink' with the 198 * user profile url and user id 199 * @return string Permanent link to user subscriptions page 200 */ 201 function bbp_get_subscriptions_permalink( $user_id = 0 ) { 202 return apply_filters( 'bbp_get_favorites_permalink', bbp_get_user_profile_url( $user_id ), $user_id ); 203 } 204 205 /** 211 206 * Output the link to subscribe/unsubscribe from a topic 212 207 * 213 * @package bbPress214 * @subpackage Template Tags215 208 * @since bbPress (r2668) 216 209 * 217 * @param mixed $args 218 * 219 * @uses bbp_get_user_subscribe_link() 220 */ 221 function bbp_user_subscribe_link ( $args = '' ) { 210 * @param mixed $args See {@link bbp_get_user_subscribe_link()} 211 * @uses bbp_get_user_subscribe_link() To get the subscribe link 212 */ 213 function bbp_user_subscribe_link( $args = '' ) { 222 214 echo bbp_get_user_subscribe_link( $args ); 223 215 } 224 216 /** 225 * bbp_get_user_subscribe_link ()226 *227 217 * Return the link to subscribe/unsubscribe from a topic 228 218 * 229 * @package bbPress230 * @subpackage Template Tags231 219 * @since bbPress (r2668) 232 220 * 233 * @param mixed $args 234 * 235 * @uses apply_filters 221 * @param mixed $args This function supports these arguments: 222 * - subscribe: Subscribe text 223 * - unsubscribe: Unsubscribe text 224 * - user_id: User id 225 * - topic_id: Topic id 226 * - before: Before the link 227 * - after: After the link 228 * @param int $user_id Optional. User id 229 * @uses bbp_get_user_id() To get the user id 230 * @uses current_user_can() To check if the current user can edit user 231 * @uses bbp_get_topic_id() To get the topic id 232 * @uses bbp_is_user_subscribed() To check if the user is subscribed 233 * @uses bbp_is_subscriptions() To check if it's the subscriptions page 234 * @uses bbp_get_subscriptions_permalink() To get subscriptions link 235 * @uses bbp_get_topic_permalink() To get topic link 236 * @uses apply_filters() Calls 'bbp_get_user_subscribe_link' with the 237 * link, args, user id & topic id 236 238 * @return string Permanent link to topic 237 239 */ 238 function bbp_get_user_subscribe_link ( $args = '', $user_id = 0 ) {240 function bbp_get_user_subscribe_link( $args = '', $user_id = 0 ) { 239 241 global $bbp; 240 242 … … 257 259 if ( !$user_id = bbp_get_user_id( $user_id, true, true ) ) 258 260 return false; 259 261 260 262 // No link if you can't edit yourself 261 263 if ( !current_user_can( 'edit_user', (int) $user_id ) ) … … 282 284 283 285 // Return the link 284 return apply_filters( 'bbp_get_user_subscribe_link', $html, $ subscribe, $unsubscribe, $user_id, $topic_id );286 return apply_filters( 'bbp_get_user_subscribe_link', $html, $args, $user_id, $topic_id ); 285 287 } 286 288 … … 288 290 289 291 /** 290 * bbp_current_user_id ()291 *292 292 * Output ID of current user 293 293 * 294 * @uses bbp_get_current_user_id() 295 */ 296 function bbp_current_user_id () { 294 * @since bbPress (r2574) 295 * 296 * @uses bbp_get_current_user_id() To get the current user id 297 */ 298 function bbp_current_user_id() { 297 299 echo bbp_get_current_user_id(); 298 300 } 299 301 /** 300 * bbp_get_current_user_id ()301 *302 302 * Return ID of current user 303 303 * 304 * @global object $current_user 305 * @global string $user_identity 306 * @return int 307 */ 308 function bbp_get_current_user_id () { 309 global $bbp; 310 311 $retval = isset( $bbp->current_user ) ? $bbp->current_user->ID : 0; 312 313 return apply_filters( 'bbp_get_current_user_id', $retval ); 314 } 315 316 /** 317 * bbp_displayed_user_id () 318 * 304 * @since bbPress (r2574) 305 * 306 * @uses bbp_get_user_id() To get the current user id 307 * @uses apply_filters() Calls 'bbp_get_current_user_id' with the id 308 * @return int Current user id 309 */ 310 function bbp_get_current_user_id() { 311 return apply_filters( 'bbp_get_current_user_id', bbp_get_user_id( 0, false, true ) ); 312 } 313 314 /** 319 315 * Output ID of displayed user 320 316 * 321 * @uses bbp_get_displayed_user_id() 322 */ 323 function bbp_displayed_user_id () { 317 * @since bbPress (r2688) 318 * 319 * @uses bbp_get_displayed_user_id() To get the displayed user id 320 */ 321 function bbp_displayed_user_id() { 324 322 echo bbp_get_displayed_user_id(); 325 323 } 326 324 /** 327 * bbp_get_displayed_user_id ()328 *329 325 * Return ID of displayed user 330 326 * 331 * @global object $displayed_user 332 * @global string $user_identity 333 * @return int 334 */ 335 function bbp_get_displayed_user_id () { 336 global $bbp; 337 338 $retval = isset( $bbp->displayed_user ) ? $bbp->displayed_user->ID : 0; 339 340 return apply_filters( 'bbp_get_displayed_user_id', $retval ); 341 } 342 343 /** 344 * bbp_get_displayed_user_field () 345 * 327 * @since bbPress (r2688) 328 * 329 * @uses bbp_get_user_id() To get the displayed user id 330 * @uses apply_filters() Calls 'bbp_get_displayed_user_id' with the id 331 * @return int Displayed user id 332 */ 333 function bbp_get_displayed_user_id() { 334 return apply_filters( 'bbp_get_displayed_user_id', bbp_get_user_id( 0, true, false ) ); 335 } 336 337 /** 346 338 * Return a sanitized user field value 347 339 * 348 * @global bbPress $bbp 349 * @param string $field 350 * @return string 351 */ 352 function bbp_get_displayed_user_field ( $field = '' ) { 340 * @since bbPress (r2688) 341 * 342 * @param string $field Field to get 343 * @uses sanitize_text_field() To sanitize the field 344 * @uses esc_attr() To sanitize the field 345 * @return string|bool Value of the field if it exists, else false 346 */ 347 function bbp_get_displayed_user_field( $field = '' ) { 353 348 global $bbp; 354 349 355 350 // Return field if exists 356 351 if ( isset( $bbp->displayed_user->$field ) ) 357 return esc_attr( sanitize_text_field ( $bbp->displayed_user->$field ) );352 return esc_attr( sanitize_text_field( $bbp->displayed_user->$field ) ); 358 353 359 354 // Return empty … … 362 357 363 358 /** 364 * bbp_current_user_name ()365 *366 359 * Output name of current user 367 360 * 368 * @uses bbp_get_current_user_name() 369 */ 370 function bbp_current_user_name () { 361 * @since bbPress (r2574) 362 * 363 * @uses bbp_get_current_user_name() To get the current user name 364 */ 365 function bbp_current_user_name() { 371 366 echo bbp_get_current_user_name(); 372 367 } 373 368 /** 374 * bbp_get_current_user_name ()375 *376 369 * Return name of current user 377 370 * 378 * @global object $current_user 379 * @global string $user_identity 371 * @since bbPress (r2574) 372 * 373 * @uses apply_filters() Calls 'bbp_get_current_user_name' with the 374 * current user name 380 375 * @return string 381 376 */ 382 function bbp_get_current_user_name () {383 global $ current_user, $user_identity;377 function bbp_get_current_user_name() { 378 global $user_identity; 384 379 385 380 if ( is_user_logged_in() ) … … 392 387 393 388 /** 394 * bbp_current_user_avatar ()395 *396 389 * Output avatar of current user 397 390 * 398 * @uses bbp_get_current_user_avatar() 399 */ 400 function bbp_current_user_avatar ( $size = 40 ) { 391 * @since bbPress (r2574) 392 * 393 * @param int $size Size of the avatar. Defaults to 40 394 * @uses bbp_get_current_user_avatar() To get the current user avatar 395 */ 396 function bbp_current_user_avatar( $size = 40 ) { 401 397 echo bbp_get_current_user_avatar( $size ); 402 398 } 403 399 404 400 /** 405 * bbp_get_current_user_avatar ( $size = 40 )406 *407 401 * Return avatar of current user 408 402 * 409 * @global object $current_user 410 * @param int $size 411 * @return string 412 */ 413 function bbp_get_current_user_avatar ( $size = 40 ) { 414 global $current_user; 415 416 return apply_filters( 'bbp_get_current_user_avatar', get_avatar( bbp_get_current_user_id(), $size ) ); 417 } 418 419 /** 420 * bbp_user_profile_link () 421 * 403 * @since bbPress (r2574) 404 * 405 * @param int $size Size of the avatar. Defaults to 40 406 * @uses bbp_get_current_user_id() To get the current user id 407 * @uses get_avatar() To get the avatar 408 * @uses apply_filters() Calls 'bbp_get_current_user_avatar' with the 409 * avatar and size 410 * @return string Current user avatar 411 */ 412 function bbp_get_current_user_avatar( $size = 40 ) { 413 return apply_filters( 'bbp_get_current_user_avatar', get_avatar( bbp_get_current_user_id(), $size ), $size ); 414 } 415 416 /** 422 417 * Output link to the profile page of a user 423 418 * 424 * @package bbPress 425 * @subpackage Template Tags 426 * @since bbPress (r2688) 427 * 428 * @uses bbp_get_user_profile_link () 429 * 430 * @param int $user_id 431 */ 432 function bbp_user_profile_link ( $user_id = 0 ) { 419 * @since bbPress (r2688) 420 * 421 * @param int $user_id Optional. User id 422 * @uses bbp_get_user_profile_link() To get user profile link 423 */ 424 function bbp_user_profile_link( $user_id = 0 ) { 433 425 echo bbp_get_user_profile_link( $user_id ); 434 426 } 435 427 /** 436 * bbp_get_user_profile_link ()437 *438 428 * Return link to the profile page of a user 439 429 * 440 * @package bbPress441 * @subpackage Template Tags442 430 * @since bbPress (r2688) 443 431 * 444 * @uses bbp_get_user_profile_url () 445 * 446 * @param int $user_id 447 * @return string 448 */ 449 function bbp_get_user_profile_link ( $user_id = 0 ) { 432 * @param int $user_id Optional. User id 433 * @uses bbp_get_user_id() To get user id 434 * @uses get_userdata() To get user data 435 * @uses bbp_get_user_profile_url() To get user profile url 436 * @uses apply_filters() Calls 'bbp_get_user_profile_link' with the user 437 * profile link and user id 438 * @return string User profile link 439 */ 440 function bbp_get_user_profile_link( $user_id = 0 ) { 450 441 if ( !$user_id = bbp_get_user_id( $user_id ) ) 451 442 return false; … … 459 450 460 451 /** 461 * bbp_user_profile_url ()462 *463 452 * Output URL to the profile page of a user 464 453 * 465 * @package bbPress 466 * @subpackage Template Tags 467 * @since bbPress (r2688) 468 * 469 * @uses bbp_get_user_profile_url () 470 * 471 * @param int $user_id 472 */ 473 function bbp_user_profile_url ( $user_id = 0, $user_nicename = '' ) { 454 * @since bbPress (r2688) 455 * 456 * @param int $user_id Optional. User id 457 * @param string $user_nicename Optional. User nicename 458 * @uses bbp_get_user_profile_url() To get user profile url 459 */ 460 function bbp_user_profile_url( $user_id = 0, $user_nicename = '' ) { 474 461 echo bbp_get_user_profile_url( $user_id ); 475 462 } 476 463 /** 477 * bbp_get_user_profile_url ()478 *479 464 * Return URL to the profile page of a user 480 465 * 481 * @package bbPress482 * @subpackage Template Tags483 466 * @since bbPress (r2688) 484 467 * 485 * @param int $user_id 486 * @param string $user_nicename 487 * 488 * @return string 489 */ 490 function bbp_get_user_profile_url ( $user_id = 0, $user_nicename = '' ) { 468 * @param int $user_id Optional. User id 469 * @param string $user_nicename Optional. User nicename 470 * @uses bbp_get_user_id() To get user id 471 * @uses add_query_arg() To add custom args to the url 472 * @uses home_url() To get blog home url 473 * @uses apply_filters() Calls 'bbp_get_user_profile_url' with the user 474 * profile url, user id and user nicename 475 * @return string User profile url 476 */ 477 function bbp_get_user_profile_url( $user_id = 0, $user_nicename = '' ) { 491 478 global $wp_rewrite, $bbp; 492 479 … … 494 481 if ( !$user_id = bbp_get_user_id( $user_id ) ) 495 482 return false; 496 497 // URL for pretty permalinks498 $url = !empty( $wp_rewrite->permalink_structure ) ? $wp_rewrite->front . $bbp->user_slug . '/%bbp_user%' : '';499 483 500 484 // No pretty permalinks 501 if ( empty( $url ) ) { 502 $file = home_url( '/' ); 503 $url = $file . '?bbp_user=' . $user_id; 485 if ( empty( $wp_rewrite->permalink_structure ) ) { 486 $url = add_query_arg( array( 'bbp_user' => $user_id ), home_url( '/' ) ); 504 487 505 488 // Get URL safe user slug 506 489 } else { 490 $url = $wp_rewrite->front . $bbp->user_slug . '/%bbp_user%'; 491 507 492 if ( empty( $user_nicename ) ) { 508 493 $user = get_userdata( $user_id ); … … 510 495 $user_nicename = $user->user_nicename; 511 496 } 497 512 498 $url = str_replace( '%bbp_user%', $user_nicename, $url ); 513 499 $url = home_url( user_trailingslashit( $url ) ); … … 519 505 520 506 /** 521 * bbp_user_profile_edit_link ()522 *523 507 * Output link to the profile edit page of a user 524 508 * 525 * @package bbPress 526 * @subpackage Template Tags 527 * @since bbPress (r2688) 528 * 529 * @uses bbp_get_user_profile_edit_link () 530 * 531 * @param int $user_id 532 */ 533 function bbp_user_profile_edit_link ( $user_id = 0 ) { 509 * @since bbPress (r2688) 510 * 511 * @param int $user_id Optional. User id 512 * @uses bbp_get_user_profile_edit_link() To get user profile edit link 513 */ 514 function bbp_user_profile_edit_link( $user_id = 0 ) { 534 515 echo bbp_get_user_profile_edit_link( $user_id ); 535 516 } 536 517 /** 537 * bbp_get_user_profile_edit_link ()538 *539 518 * Return link to the profile edit page of a user 540 519 * 541 * @package bbPress542 * @subpackage Template Tags543 520 * @since bbPress (r2688) 544 521 * 545 * @uses bbp_get_user_profile_edit_url () 546 * 547 * @param int $user_id 548 * @return string 549 */ 550 function bbp_get_user_profile_edit_link ( $user_id = 0 ) { 522 * @param int $user_id Optional. User id 523 * @uses bbp_get_user_id() To get user id 524 * @uses get_userdata() To get user data 525 * @uses bbp_get_user_profile_edit_url() To get user profile edit url 526 * @uses apply_filters() Calls 'bbp_get_user_profile_link' with the edit 527 * link and user id 528 * @return string User profile edit link 529 */ 530 function bbp_get_user_profile_edit_link( $user_id = 0 ) { 551 531 if ( !$user_id = bbp_get_user_id( $user_id ) ) 552 532 return false; … … 559 539 560 540 /** 561 * bbp_user_profile_edit_url ()562 *563 541 * Output URL to the profile edit page of a user 564 542 * 565 * @package bbPress 566 * @subpackage Template Tags 567 * @since bbPress (r2688) 568 * 569 * @uses bbp_get_user_edit_profile_url () 570 * 571 * @param int $user_id 572 */ 573 function bbp_user_profile_edit_url ( $user_id = 0, $user_nicename = '' ) { 543 * @since bbPress (r2688) 544 * 545 * @param int $user_id Optional. User id 546 * @param string $user_nicename Optional. User nicename 547 * @uses bbp_get_user_profile_edit_url() To get user profile edit url 548 */ 549 function bbp_user_profile_edit_url( $user_id = 0, $user_nicename = '' ) { 574 550 echo bbp_get_user_profile_edit_url( $user_id ); 575 551 } 576 552 /** 577 * bbp_get_user_profile_edit_url ()578 *579 553 * Return URL to the profile edit page of a user 580 554 * 581 * @package bbPress582 * @subpackage Template Tags583 555 * @since bbPress (r2688) 584 556 * 585 * @param int $user_id 586 * @param string $user_nicename 587 * 557 * @param int $user_id Optional. User id 558 * @param string $user_nicename Optional. User nicename 559 * @uses bbp_get_user_id() To get user id 560 * @uses add_query_arg() To add custom args to the url 561 * @uses home_url() To get blog home url 562 * @uses apply_filters() Calls 'bbp_get_user_edit_profile_url' with the 563 * edit profile url, user id and user nicename 588 564 * @return string 589 565 */ 590 function bbp_get_user_profile_edit_url ( $user_id = 0, $user_nicename = '' ) {566 function bbp_get_user_profile_edit_url( $user_id = 0, $user_nicename = '' ) { 591 567 global $wp_rewrite, $bbp; 592 568 … … 594 570 return; 595 571 596 $url = !empty( $wp_rewrite->permalink_structure ) ? $wp_rewrite->front . $bbp->user_slug . '/%bbp_user%/edit' : ''; 597 598 if ( empty( $url ) ) { 599 $url = add_query_arg( array( 'bbp_user' => $user_id, 'bbp_edit_profile' => '1' ), home_url( '/' ) ); 572 if ( empty( $wp_rewrite->permalink_structure ) ) { 573 $url = add_query_arg( array( 'bbp_user' => $user_id, 'edit' => '1' ), home_url( '/' ) ); 600 574 } else { 575 $url = $wp_rewrite->front . $bbp->user_slug . '/%bbp_user%/edit'; 576 601 577 if ( empty( $user_nicename ) ) { 602 578 $user = get_userdata( $user_id ); … … 604 580 $user_nicename = $user->user_nicename; 605 581 } 582 606 583 $url = str_replace( '%bbp_user%', $user_nicename, $url ); 607 584 $url = home_url( user_trailingslashit( $url ) ); … … 615 592 616 593 /** 617 * bbp_edit_user_success () 618 */ 619 function bbp_notice_edit_user_success () { 594 * Edit profile success message 595 * 596 * @since bbPress (r2688) 597 * 598 * @uses bbp_is_user_profile_page() To check if it's the profile page 599 * @uses bbp_is_user_profile_edit() To check if it's the profile edit page 600 */ 601 function bbp_notice_edit_user_success() { 620 602 if ( isset( $_GET['updated'] ) && ( bbp_is_user_profile_page() || bbp_is_user_profile_edit() ) ) : ?> 621 603 … … 626 608 <?php endif; 627 609 } 628 add_action( 'bbp_template_notices', 'bbp_notice_edit_user_success' ); 629 630 function bbp_notice_edit_user_is_super_admin () { 610 611 /** 612 * Super admin privileges notice 613 * 614 * @since bbPress (r2688) 615 * 616 * @uses is_multisite() To check if the blog is multisite 617 * @uses bbp_is_user_profile_page() To check if it's the profile page 618 * @uses bbp_is_user_profile_edit() To check if it's the profile edit page 619 * @uses current_user_can() To check if the current user can manage network 620 * options 621 * @uses bbp_get_displayed_user_id() To get the displayed user id 622 * @uses is_super_admin() To check if the user is super admin 623 * @uses bbp_is_user_home() To check if it's the user home 624 */ 625 function bbp_notice_edit_user_is_super_admin() { 631 626 if ( is_multisite() && ( bbp_is_user_profile_page() || bbp_is_user_profile_edit() ) && current_user_can( 'manage_network_options' ) && is_super_admin( bbp_get_displayed_user_id() ) ) : ?> 632 627 … … 637 632 <?php endif; 638 633 } 639 add_action( 'bbp_template_notices', 'bbp_notice_edit_user_is_super_admin', 2 ); 640 641 /** 642 * bbp_edit_user_display_name() 643 * 634 635 /** 644 636 * Drop down for selecting the user's display name 645 637 * 646 * @ global bbPress $bbp647 */ 648 function bbp_edit_user_display_name () {638 * @since bbPress (r2688) 639 */ 640 function bbp_edit_user_display_name() { 649 641 global $bbp; 650 642 … … 684 676 685 677 /** 686 * bbp_edit_user_role ()687 *688 678 * Output role selector (for user edit) 689 679 * 690 * @package bbPress 691 * @subpackage Template 692 * 693 * @param string $default slug for the role that should be already selected 694 */ 695 function bbp_edit_user_role () { 680 * @since bbPress (r2688) 681 */ 682 function bbp_edit_user_role() { 696 683 global $bbp; 697 684 … … 722 709 } 723 710 724 function bbp_edit_user_contact_methods( $user_id = 0 ) { 711 /** 712 * Return user contact methods Selectbox 713 * 714 * @since bbPress (r2688) 715 * 716 * @return string user contact methods 717 */ 718 function bbp_edit_user_contact_methods() { 725 719 global $bbp; 726 720
Note: See TracChangeset
for help on using the changeset viewer.