| 469 | |
| 470 | if ( !class_exists( 'BP_XProfile_User_Admin' ) ) : |
| 471 | /** |
| 472 | * Load xProfile user's profile admin area. |
| 473 | * |
| 474 | * @package BuddyPress |
| 475 | * @subpackage xProfileAdministration |
| 476 | * |
| 477 | * @since BuddyPress (?) |
| 478 | */ |
| 479 | class BP_XProfile_User_Admin { |
| 480 | |
| 481 | /** |
| 482 | * screen id for edit user's profile page. |
| 483 | * |
| 484 | * @access public |
| 485 | * @var string |
| 486 | */ |
| 487 | public $user_page = ''; |
| 488 | |
| 489 | /** |
| 490 | * Constructor method. |
| 491 | * |
| 492 | * @access public |
| 493 | * @since BuddyPress (?) |
| 494 | */ |
| 495 | public function __construct() { |
| 496 | $this->setup_globals(); |
| 497 | $this->setup_actions(); |
| 498 | } |
| 499 | |
| 500 | /** |
| 501 | * Set admin-related globals. |
| 502 | * |
| 503 | * @access private |
| 504 | * @since BuddyPress (?) |
| 505 | */ |
| 506 | private function setup_globals() { |
| 507 | $bp = buddypress(); |
| 508 | |
| 509 | // Paths and URLs |
| 510 | $this->admin_dir = trailingslashit( $bp->plugin_dir . 'bp-xprofile/admin' ); // Admin path |
| 511 | $this->admin_url = trailingslashit( $bp->plugin_url . 'bp-xprofile/admin' ); // Admin url |
| 512 | $this->css_url = trailingslashit( $this->admin_url . 'css' ); // Admin css URL |
| 513 | $this->js_url = trailingslashit( $this->admin_url . 'js' ); // Admin css URL |
| 514 | |
| 515 | // Main settings page |
| 516 | $this->settings_page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php'; |
| 517 | |
| 518 | // The Edit Profile Screen id |
| 519 | $this->user_page = ''; |
| 520 | |
| 521 | // The screen ids to load specific css for |
| 522 | $this->screen_id = array(); |
| 523 | |
| 524 | // The WordPress edit user url |
| 525 | $this->edit_url = bp_get_admin_url( 'user-edit.php' ); |
| 526 | |
| 527 | // BuddyPress edit user's profile url |
| 528 | $this->edit_profile_url = add_query_arg( 'page', 'bp-profile-edit', bp_get_admin_url( 'users.php' ) ); |
| 529 | } |
| 530 | |
| 531 | /** |
| 532 | * Set admin-related actions and filters. |
| 533 | * |
| 534 | * @access private |
| 535 | * @since BuddyPress (?) |
| 536 | * |
| 537 | * @uses add_action() To add various actions. |
| 538 | * @uses add_filter() To add various filters. |
| 539 | */ |
| 540 | private function setup_actions() { |
| 541 | |
| 542 | /** Actions ***********************************************************/ |
| 543 | |
| 544 | // Add some page specific output to the <head> |
| 545 | add_action( 'bp_admin_head', array( $this, 'admin_head' ), 999 ); |
| 546 | |
| 547 | // Add menu item to all users menu |
| 548 | add_action( bp_core_admin_hook(), array( $this, 'admin_menus' ), 5 ); |
| 549 | |
| 550 | // Enqueue all admin JS and CSS |
| 551 | add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
| 552 | |
| 553 | // Create the Profile Navigation (WordPress/Community) |
| 554 | add_action( 'edit_user_profile', array( $this, 'profile_nav' ), 99, 1 ); |
| 555 | |
| 556 | |
| 557 | /** Filters ***********************************************************/ |
| 558 | |
| 559 | // Add a row action to users listing |
| 560 | add_filter( bp_core_do_network_admin() ? 'ms_user_row_actions' : 'user_row_actions', array( $this, 'row_actions' ), 10, 2 ); |
| 561 | |
| 562 | } |
| 563 | |
| 564 | /** |
| 565 | * Create the All users Edit Profile submenu |
| 566 | * |
| 567 | * @access public |
| 568 | * @since BuddyPress (?) |
| 569 | * |
| 570 | * @uses add_users_page() To add the Edit Profile page in Users section. |
| 571 | */ |
| 572 | public function admin_menus() { |
| 573 | |
| 574 | // Manage user's profile |
| 575 | $hook = $this->user_page = add_users_page( |
| 576 | __( 'Edit Profile', 'buddypress' ), |
| 577 | __( 'Edit Profile', 'buddypress' ), |
| 578 | 'bp_moderate', |
| 579 | 'bp-profile-edit', |
| 580 | array( &$this, 'user_admin' ) |
| 581 | ); |
| 582 | |
| 583 | $edit_page = 'user-edit'; |
| 584 | |
| 585 | if ( bp_core_do_network_admin() ) { |
| 586 | $edit_page .= '-network'; |
| 587 | $this->user_page .= '-network'; |
| 588 | } |
| 589 | |
| 590 | $this->screen_id = array( $edit_page, $this->user_page ); |
| 591 | |
| 592 | add_action( "admin_head-$hook", array( $this, 'modify_admin_menu_highlight' ) ); |
| 593 | add_action( "load-$hook", array( $this, 'user_admin_load' ) ); |
| 594 | |
| 595 | } |
| 596 | |
| 597 | /** |
| 598 | * Add some specific styling to the Edit user and Edit user's profile page. |
| 599 | * |
| 600 | * @access public |
| 601 | * @since BuddyPress (?) |
| 602 | */ |
| 603 | public function enqueue_scripts() { |
| 604 | if ( ! in_array( get_current_screen()->id, $this->screen_id ) ) { |
| 605 | return; |
| 606 | } |
| 607 | |
| 608 | $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 609 | |
| 610 | $file = $this->css_url . "admin{$min}.css"; |
| 611 | $file = apply_filters( 'bp_xprofile_admin_css', $file ); |
| 612 | wp_enqueue_style( 'bp-xprofile-css', $file, array(), bp_get_version() ); |
| 613 | |
| 614 | // Plugins may want to hook here to load some css/js |
| 615 | do_action( 'bp_xprofile_user_admin_enqueue_scripts', get_current_screen()->id, $this->screen_id ); |
| 616 | } |
| 617 | |
| 618 | /** |
| 619 | * Create the Profile navigation in Edit User & Edit Profile pages |
| 620 | * |
| 621 | * @access public |
| 622 | * @since BuddyPress (?) |
| 623 | */ |
| 624 | public function profile_nav( $user = null, $active = 'WordPress' ) { |
| 625 | |
| 626 | if ( empty( $user->ID ) ) { |
| 627 | return; |
| 628 | } |
| 629 | |
| 630 | $query_args = array( 'user_id' => $user->ID ); |
| 631 | |
| 632 | if ( ! empty( $_REQUEST['wp_http_referer'] ) ) { |
| 633 | $query_args['wp_http_referer'] = urlencode( wp_unslash( $_REQUEST['wp_http_referer'] ) ); |
| 634 | } |
| 635 | |
| 636 | $community_url = add_query_arg( $query_args, $this->edit_profile_url ); |
| 637 | $wordpress_url = add_query_arg( $query_args, $this->edit_url ); |
| 638 | |
| 639 | $bp_active = false; |
| 640 | $wp_active = ' nav-tab-active'; |
| 641 | if ( 'BuddyPress' == $active ) { |
| 642 | $bp_active = ' nav-tab-active'; |
| 643 | $wp_active = false; |
| 644 | } |
| 645 | |
| 646 | ?> |
| 647 | <ul id="profile-nav" class="nav-tab-wrapper"> |
| 648 | <li class="nav-tab<?php echo $wp_active;?>"><a href="<?php echo $wordpress_url;?>"><?php _e( 'WordPress Profile' ); ?></a></li> |
| 649 | <li class="nav-tab<?php echo $bp_active;?>"><a href="<?php echo $community_url;?>"><?php _e( 'Community Profile' ); ?></a></li> |
| 650 | </ul> |
| 651 | <?php |
| 652 | } |
| 653 | |
| 654 | /** |
| 655 | * Highlight the All users menu if on Edit Profile pages |
| 656 | * |
| 657 | * @access public |
| 658 | * @since BuddyPress (?) |
| 659 | * |
| 660 | * @global $plugin_page |
| 661 | * @global $submenu_file |
| 662 | */ |
| 663 | public function modify_admin_menu_highlight() { |
| 664 | global $plugin_page, $submenu_file; |
| 665 | |
| 666 | // Only Show the All users menu |
| 667 | if ( 'bp-profile-edit' == $plugin_page ) { |
| 668 | $submenu_file = 'users.php'; |
| 669 | } |
| 670 | } |
| 671 | |
| 672 | /** |
| 673 | * Remove the Edit Profile submenu page |
| 674 | * |
| 675 | * @access public |
| 676 | * @since BuddyPress (?) |
| 677 | */ |
| 678 | public function admin_head() { |
| 679 | // Remove submenu to force using Profile Navigation |
| 680 | remove_submenu_page( 'users.php', 'bp-profile-edit' ); |
| 681 | } |
| 682 | |
| 683 | /** |
| 684 | * Set up the User's profile admin page. |
| 685 | * |
| 686 | * Loaded before the page is rendered, this function does all initial setup, |
| 687 | * including: processing form requests, registering contextual help, and |
| 688 | * setting up screen options. |
| 689 | * |
| 690 | * @access public |
| 691 | * @since BuddyPress (?) |
| 692 | */ |
| 693 | public function user_admin_load() { |
| 694 | |
| 695 | if ( ! $user_id = intval( $_GET['user_id'] ) ) { |
| 696 | wp_die( __( 'No users were found', 'buddypress' ) ); |
| 697 | } |
| 698 | |
| 699 | $bp = buddypress(); |
| 700 | |
| 701 | /** |
| 702 | * Sets displayed user id if empty on the user's profile admin page. |
| 703 | * this is probably not the right way to do it. But bp_get_the_profile_field_options() args |
| 704 | * does not accept a user_id parameter and for instance, bp_displayed_user_id() is used in |
| 705 | * BP_XProfile_ProfileData::get_value_byid() to retrieve datas. |
| 706 | */ |
| 707 | if ( empty( $bp->displayed_user->id ) ) { |
| 708 | |
| 709 | // Let's set the user displayed id |
| 710 | $bp->displayed_user->id = $user_id; |
| 711 | |
| 712 | // The domain for the user currently being displayed |
| 713 | $bp->displayed_user->domain = bp_core_get_user_domain( bp_displayed_user_id() ); |
| 714 | |
| 715 | // The core userdata of the user who is currently being displayed |
| 716 | $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() ); |
| 717 | |
| 718 | // Fetch the full name displayed user |
| 719 | $bp->displayed_user->fullname = bp_core_get_user_displayname( bp_displayed_user_id() ); |
| 720 | } |
| 721 | |
| 722 | // Build redirection URL |
| 723 | $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham', 'delete_avatar' ), $_SERVER['REQUEST_URI'] ); |
| 724 | $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : false; |
| 725 | |
| 726 | if ( ! empty( $_REQUEST['user_status'] ) ) { |
| 727 | $spam = ( 'spam' == $_REQUEST['user_status'] ) ? true : false ; |
| 728 | |
| 729 | if ( $spam != bp_is_user_spammer( $user_id ) ) { |
| 730 | $doaction = $_REQUEST['user_status']; |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | // Call an action for plugins to hook in early |
| 735 | do_action_ref_array( 'bp_xprofile_user_admin_load', array( $doaction, $_REQUEST ) ); |
| 736 | |
| 737 | // Prepare the display of the Community Profile screen |
| 738 | if ( ! in_array( $doaction, array( 'update', 'delete_avatar', 'spam', 'ham' ) ) ) { |
| 739 | add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) ); |
| 740 | |
| 741 | get_current_screen()->add_help_tab( array( |
| 742 | 'id' => 'bp-profile-edit-overview', |
| 743 | 'title' => __( 'Overview', 'buddypress' ), |
| 744 | 'content' => |
| 745 | '<p>' . __( 'This is the admin view of a user's profile.', 'buddypress' ) . '</p>' . |
| 746 | '<p>' . __( 'You can edit the different fields of his extended profile from the main metabox', 'buddypress' ) . '</p>' . |
| 747 | '<p>' . __( 'You can get some interesting informations about him on right side metaboxes', 'buddypress' ) . '</p>' |
| 748 | ) ); |
| 749 | |
| 750 | // Help panel - sidebar links |
| 751 | get_current_screen()->set_help_sidebar( |
| 752 | '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' . |
| 753 | '<p>' . __( '<a href="http://codex.buddypress.org/buddypress-site-administration/managing-user-profiles/">Managing Profiles</a>', 'buddypress' ) . '</p>' . |
| 754 | '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>' |
| 755 | ); |
| 756 | |
| 757 | // Register metaboxes for the edit screen. |
| 758 | add_meta_box( 'submitdiv', _x( 'Status', 'xprofile user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_status_metabox' ), get_current_screen()->id, 'side', 'core' ); |
| 759 | |
| 760 | // Each Group of fields will have his own metabox |
| 761 | if ( false == bp_is_user_spammer( $user_id ) && bp_has_profile( array( 'fetch_fields' => false ) ) ) { |
| 762 | while ( bp_profile_groups() ) : bp_the_profile_group(); |
| 763 | add_meta_box( 'bp_xprofile_user_admin_fields_' . bp_get_the_profile_group_slug(), bp_get_the_profile_group_name(), array( &$this, 'user_admin_profile_metaboxes' ), get_current_screen()->id, 'normal', 'core', array( 'profile_group_id' => bp_get_the_profile_group_id() ) ); |
| 764 | endwhile; |
| 765 | |
| 766 | // if a user has been mark as a spammer, his BuddyPress datas are removed ! |
| 767 | } else { |
| 768 | add_meta_box( 'bp_xprofile_user_admin_empty_profile', _x( 'User marked as a spammer', 'xprofile user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_spammer_metabox' ), get_current_screen()->id, 'normal', 'core' ); |
| 769 | } |
| 770 | |
| 771 | // Avatar Metabox |
| 772 | add_meta_box( 'bp_xprofile_user_admin_avatar', _x( 'Avatar', 'xprofile user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_avatar_metabox' ), get_current_screen()->id, 'side', 'low' ); |
| 773 | |
| 774 | // User Stat metabox |
| 775 | add_meta_box( 'bp_xprofile_user_admin_stat', _x( 'Stats', 'xprofile user-admin edit screen', 'buddypress' ), array( &$this, 'user_admin_stats_metabox' ), get_current_screen()->id, 'side', 'low' ); |
| 776 | |
| 777 | // Custom metabox ? |
| 778 | do_action( 'bp_xprofile_user_admin_metaboxes' ); |
| 779 | |
| 780 | // Enqueue javascripts |
| 781 | wp_enqueue_script( 'postbox' ); |
| 782 | wp_enqueue_script( 'dashboard' ); |
| 783 | wp_enqueue_script( 'comment' ); |
| 784 | |
| 785 | // Spam or Ham user |
| 786 | } else if ( in_array( $doaction, array( 'spam', 'ham' ) ) ) { |
| 787 | |
| 788 | check_admin_referer( 'edit-bp-profile_' . $user_id ); |
| 789 | |
| 790 | if ( bp_core_process_spammer_status( $user_id, $doaction ) ) { |
| 791 | $redirect_to = add_query_arg( 'updated', $doaction, $redirect_to ); |
| 792 | } else { |
| 793 | $redirect_to = add_query_arg( 'error', $doaction, $redirect_to ); |
| 794 | } |
| 795 | |
| 796 | bp_core_redirect( $redirect_to ); |
| 797 | |
| 798 | // Delete avatar |
| 799 | } else if ( 'delete_avatar' == $doaction ) { |
| 800 | |
| 801 | check_admin_referer( 'delete_avatar' ); |
| 802 | |
| 803 | $redirect_to = remove_query_arg( '_wpnonce', $redirect_to ); |
| 804 | |
| 805 | if ( bp_core_delete_existing_avatar( array( 'item_id' => $user_id ) ) ) { |
| 806 | $redirect_to = add_query_arg( 'updated', 'avatar', $redirect_to ); |
| 807 | } else { |
| 808 | $redirect_to = add_query_arg( 'error', 'avatar', $redirect_to ); |
| 809 | } |
| 810 | |
| 811 | bp_core_redirect( $redirect_to ); |
| 812 | |
| 813 | // Update fields |
| 814 | } else { |
| 815 | |
| 816 | // Check to see if any new information has been submitted |
| 817 | if ( isset( $_POST['field_ids'] ) ) { |
| 818 | |
| 819 | // Check the nonce |
| 820 | check_admin_referer( 'edit-bp-profile_' . $user_id ); |
| 821 | |
| 822 | // Check we have field ID's |
| 823 | if ( empty( $_POST['field_ids'] ) ) { |
| 824 | $redirect_to = add_query_arg( 'error', '1', $redirect_to ); |
| 825 | bp_core_redirect( $redirect_to ); |
| 826 | } |
| 827 | |
| 828 | $merge_ids = ''; |
| 829 | foreach ( $_POST['field_ids'] as $ids ) { |
| 830 | $merge_ids .= $ids . ','; |
| 831 | } |
| 832 | |
| 833 | // Explode the posted field IDs into an array so we know which |
| 834 | // fields have been submitted |
| 835 | $posted_field_ids = array_filter( wp_parse_id_list( $merge_ids ) ); |
| 836 | $is_required = array(); |
| 837 | |
| 838 | // Loop through the posted fields formatting any datebox values |
| 839 | // then validate the field |
| 840 | foreach ( (array) $posted_field_ids as $field_id ) { |
| 841 | if ( !isset( $_POST['field_' . $field_id] ) ) { |
| 842 | if ( !empty( $_POST['field_' . $field_id . '_day'] ) && !empty( $_POST['field_' . $field_id . '_month'] ) && !empty( $_POST['field_' . $field_id . '_year'] ) ) { |
| 843 | // Concatenate the values |
| 844 | $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year']; |
| 845 | |
| 846 | // Turn the concatenated value into a timestamp |
| 847 | $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) ); |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | $is_required[$field_id] = xprofile_check_is_required_field( $field_id ); |
| 852 | if ( $is_required[$field_id] && empty( $_POST['field_' . $field_id] ) ) { |
| 853 | $redirect_to = add_query_arg( 'error', '2', $redirect_to ); |
| 854 | bp_core_redirect( $redirect_to ); |
| 855 | } |
| 856 | } |
| 857 | |
| 858 | // Set the errors var |
| 859 | $errors = false; |
| 860 | |
| 861 | // Now we've checked for required fields, lets save the values. |
| 862 | foreach ( (array) $posted_field_ids as $field_id ) { |
| 863 | |
| 864 | // 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. |
| 865 | if ( empty( $_POST['field_' . $field_id] ) ) { |
| 866 | $value = array(); |
| 867 | } else { |
| 868 | $value = $_POST['field_' . $field_id]; |
| 869 | } |
| 870 | |
| 871 | if ( !xprofile_set_field_data( $field_id, $user_id, $value, $is_required[$field_id] ) ) { |
| 872 | $errors = true; |
| 873 | } else { |
| 874 | do_action( 'xprofile_profile_field_data_updated', $field_id, $value ); |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | do_action( 'xprofile_updated_profile', $user_id, $posted_field_ids, $errors ); |
| 879 | |
| 880 | // Set the feedback messages |
| 881 | if ( !empty( $errors ) ) { |
| 882 | $redirect_to = add_query_arg( 'error', '3', $redirect_to ); |
| 883 | } else { |
| 884 | $redirect_to = add_query_arg( 'updated', '1', $redirect_to ); |
| 885 | } |
| 886 | |
| 887 | bp_core_redirect( $redirect_to ); |
| 888 | } |
| 889 | |
| 890 | do_action( 'xprofile_screen_edit_profile' ); |
| 891 | } |
| 892 | } |
| 893 | |
| 894 | /** |
| 895 | * Display the user's profile. |
| 896 | * |
| 897 | * @access public |
| 898 | * @since BuddyPress (?) |
| 899 | */ |
| 900 | public function user_admin() { |
| 901 | |
| 902 | if ( ! current_user_can( 'bp_moderate' ) ) { |
| 903 | die( '-1' ); |
| 904 | } |
| 905 | |
| 906 | $user = get_user_to_edit( $_GET['user_id'] ); |
| 907 | |
| 908 | // Construct URL for form |
| 909 | $form_url = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham' ), $_SERVER['REQUEST_URI'] ); |
| 910 | $form_url = add_query_arg( 'action', 'update', $form_url ); |
| 911 | $wp_http_referer = remove_query_arg( array( 'action', 'updated' ), $_REQUEST['wp_http_referer'] ); |
| 912 | |
| 913 | // Prepare notice for admin |
| 914 | $notice = array(); |
| 915 | |
| 916 | if ( ! empty( $_REQUEST['updated'] ) ) { |
| 917 | switch ( $_REQUEST['updated'] ) { |
| 918 | case 'avatar': |
| 919 | $notice = array( |
| 920 | 'class' => 'updated', |
| 921 | 'message' => __( 'Avatar was deleted successfully!', 'buddypress' ) |
| 922 | ); |
| 923 | break; |
| 924 | case 'ham' : |
| 925 | $notice = array( |
| 926 | 'class' => 'updated', |
| 927 | 'message' => __( 'User removed as spammer.', 'buddypress' ) |
| 928 | ); |
| 929 | break; |
| 930 | case 'spam' : |
| 931 | $notice = array( |
| 932 | 'class' => 'updated', |
| 933 | 'message' => __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) |
| 934 | ); |
| 935 | break; |
| 936 | case 1 : |
| 937 | $notice = array( |
| 938 | 'class' => 'updated', |
| 939 | 'message' => __( 'Profile updated.', 'buddypress' ) |
| 940 | ); |
| 941 | break; |
| 942 | } |
| 943 | } |
| 944 | |
| 945 | if ( ! empty( $_REQUEST['error'] ) ) { |
| 946 | switch ( $_REQUEST['error'] ) { |
| 947 | case 'avatar': |
| 948 | $notice = array( |
| 949 | 'class' => 'error', |
| 950 | 'message' => __( 'There was a problem deleting that avatar, please try again.', 'buddypress' ) |
| 951 | ); |
| 952 | break; |
| 953 | case 'ham' : |
| 954 | $notice = array( |
| 955 | 'class' => 'error', |
| 956 | 'message' => __( 'User could not be removed as spammer.', 'buddypress' ) |
| 957 | ); |
| 958 | break; |
| 959 | case 'spam' : |
| 960 | $notice = array( |
| 961 | 'class' => 'error', |
| 962 | 'message' => __( 'User could not be marked as spammer.', 'buddypress' ) |
| 963 | ); |
| 964 | break; |
| 965 | case 1 : |
| 966 | $notice = array( |
| 967 | 'class' => 'error', |
| 968 | 'message' => __( 'An error occured while trying to update the profile.', 'buddypress' ) |
| 969 | ); |
| 970 | break; |
| 971 | case 2: |
| 972 | $notice = array( |
| 973 | 'class' => 'error', |
| 974 | 'message' => __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ) |
| 975 | ); |
| 976 | break; |
| 977 | case 3: |
| 978 | $notice = array( |
| 979 | 'class' => 'error', |
| 980 | 'message' => __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' ) |
| 981 | ); |
| 982 | break; |
| 983 | } |
| 984 | } |
| 985 | |
| 986 | if ( ! empty( $notice ) ) : |
| 987 | if ( 'updated' === $notice['class'] ) : ?> |
| 988 | <div id="message" class="<?php echo esc_attr( $notice['class'] ); ?>"> |
| 989 | <?php else: ?> |
| 990 | <div class="<?php echo esc_attr( $notice['class'] ); ?>"> |
| 991 | <?php endif; ?> |
| 992 | <p><?php echo $notice['message']; ?></p> |
| 993 | <?php if ( !empty( $wp_http_referer ) && ( 'updated' === $notice['class'] ) ) : ?> |
| 994 | <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e( '← Back to Users', 'buddypress' ); ?></a></p> |
| 995 | <?php endif; ?> |
| 996 | </div> |
| 997 | <?php endif; ?> |
| 998 | |
| 999 | <div class="wrap" id="community-profile-page"> |
| 1000 | <?php screen_icon( 'users' ); ?> |
| 1001 | <h2> |
| 1002 | <?php |
| 1003 | _e( 'Edit User', 'buddypress' ); |
| 1004 | if ( current_user_can( 'create_users' ) ) { ?> |
| 1005 | <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user', 'buddypress' ); ?></a> |
| 1006 | <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> |
| 1007 | <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user', 'buddypress' ); ?></a> |
| 1008 | <?php } |
| 1009 | ?> |
| 1010 | </h2> |
| 1011 | |
| 1012 | <?php if ( ! empty( $user ) ) : |
| 1013 | |
| 1014 | $this->profile_nav( $user, 'BuddyPress' ); ?> |
| 1015 | |
| 1016 | <form action="<?php echo esc_attr( $form_url ); ?>" id="your-profile" method="post"> |
| 1017 | <div id="poststuff"> |
| 1018 | |
| 1019 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
| 1020 | <div id="post-body-content"> |
| 1021 | </div><!-- #post-body-content --> |
| 1022 | |
| 1023 | <div id="postbox-container-1" class="postbox-container"> |
| 1024 | <?php do_meta_boxes( get_current_screen()->id, 'side', $user ); ?> |
| 1025 | </div> |
| 1026 | |
| 1027 | <div id="postbox-container-2" class="postbox-container"> |
| 1028 | <?php do_meta_boxes( get_current_screen()->id, 'normal', $user ); ?> |
| 1029 | <?php do_meta_boxes( get_current_screen()->id, 'advanced', $user ); ?> |
| 1030 | </div> |
| 1031 | </div><!-- #post-body --> |
| 1032 | |
| 1033 | </div><!-- #poststuff --> |
| 1034 | |
| 1035 | <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
| 1036 | <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
| 1037 | <?php wp_nonce_field( 'edit-bp-profile_' . $user->ID ); ?> |
| 1038 | |
| 1039 | </form> |
| 1040 | |
| 1041 | <?php else : ?> |
| 1042 | <p><?php printf( __( 'No user found with this ID. <a href="%s">Go back and try again</a>.', 'buddypress' ), esc_url( bp_get_admin_url( 'users.php' ) ) ); ?></p> |
| 1043 | <?php endif; ?> |
| 1044 | |
| 1045 | </div><!-- .wrap --> |
| 1046 | <?php |
| 1047 | } |
| 1048 | |
| 1049 | /** |
| 1050 | * Renders the Status metabox for user's profile screen. |
| 1051 | * |
| 1052 | * Actions are : |
| 1053 | * - Update profile fields |
| 1054 | * - Spam/Unspam user |
| 1055 | * |
| 1056 | * @access public |
| 1057 | * @since BuddyPress (?) |
| 1058 | * |
| 1059 | * @param WP_User $user The WP_User object for the user's profile to edit |
| 1060 | */ |
| 1061 | public function user_admin_status_metabox( $user = null ) { |
| 1062 | |
| 1063 | if ( empty( $user->ID ) ) { |
| 1064 | return; |
| 1065 | } ?> |
| 1066 | |
| 1067 | <div class="submitbox" id="submitcomment"> |
| 1068 | |
| 1069 | <div id="minor-publishing"> |
| 1070 | <div id="minor-publishing-actions"> |
| 1071 | <div id="preview-action"> |
| 1072 | <a class="button preview" href="<?php echo esc_attr( bp_core_get_user_domain( $user->ID ) ); ?>" target="_blank"><?php _e( 'View Profile', 'buddypress' ); ?></a> |
| 1073 | </div> |
| 1074 | |
| 1075 | <div class="clear"></div> |
| 1076 | </div><!-- #minor-publishing-actions --> |
| 1077 | |
| 1078 | <div id="misc-publishing-actions"> |
| 1079 | <div class="misc-pub-section" id="comment-status-radio"> |
| 1080 | <label class="approved"><input type="radio" name="user_status" value="ham" <?php checked( bp_is_user_spammer( $user->ID ), false ); ?>><?php _e( 'Active', 'buddypress' ); ?></label><br /> |
| 1081 | <label class="spam"><input type="radio" name="user_status" value="spam" <?php checked( bp_is_user_spammer( $user->ID ), true ); ?>><?php _e( 'Spammer', 'buddypress' ); ?></label> |
| 1082 | </div> |
| 1083 | |
| 1084 | <div class="misc-pub-section curtime misc-pub-section-last"> |
| 1085 | <?php |
| 1086 | // translators: Publish box date format, see http://php.net/date |
| 1087 | $datef = __( 'M j, Y @ G:i', 'buddypress' ); |
| 1088 | $date = date_i18n( $datef, strtotime( $user->user_registered ) ); |
| 1089 | ?> |
| 1090 | <span id="timestamp"><?php printf( __( 'Registered on: <strong>%1$s</strong>', 'buddypress' ), $date ); ?></span> |
| 1091 | |
| 1092 | <div id='timestampdiv' class='hide-if-js'> |
| 1093 | <?php touch_time( 1, 0, 5 ); ?> |
| 1094 | </div><!-- #timestampdiv --> |
| 1095 | </div> |
| 1096 | </div> <!-- #misc-publishing-actions --> |
| 1097 | |
| 1098 | <div class="clear"></div> |
| 1099 | </div><!-- #minor-publishing --> |
| 1100 | |
| 1101 | <div id="major-publishing-actions"> |
| 1102 | <div id="publishing-action"> |
| 1103 | <?php submit_button( __( 'Update Profile', 'buddypress' ), 'primary', 'save', false, array( 'tabindex' => '4' ) ); ?> |
| 1104 | </div> |
| 1105 | <div class="clear"></div> |
| 1106 | </div><!-- #major-publishing-actions --> |
| 1107 | |
| 1108 | </div><!-- #submitcomment --> |
| 1109 | |
| 1110 | <?php |
| 1111 | } |
| 1112 | |
| 1113 | /** |
| 1114 | * Renders the xprofile metabox for user's profile screen. |
| 1115 | * |
| 1116 | * @access public |
| 1117 | * @since BuddyPress (?) |
| 1118 | * |
| 1119 | * @param WP_User $user The WP_User object for the user's profile to edit |
| 1120 | */ |
| 1121 | public function user_admin_profile_metaboxes( $user = null, $args = array() ) { |
| 1122 | |
| 1123 | if ( empty( $user->ID ) ) { |
| 1124 | return; |
| 1125 | } |
| 1126 | |
| 1127 | $r = bp_parse_args( $args['args'], array( |
| 1128 | 'profile_group_id' => 0, |
| 1129 | 'user_id' => $user->ID |
| 1130 | ), 'bp_xprofile_user_admin_profile_loop_args' ); |
| 1131 | |
| 1132 | // We really need these args |
| 1133 | if ( empty( $r['profile_group_id'] ) || empty( $r['user_id'] ) ) { |
| 1134 | return; |
| 1135 | } |
| 1136 | |
| 1137 | if ( bp_has_profile( $r ) ) : |
| 1138 | |
| 1139 | while ( bp_profile_groups() ) : bp_the_profile_group(); ?> |
| 1140 | |
| 1141 | <p class="description"><?php bp_the_profile_group_description(); ?></p> |
| 1142 | |
| 1143 | <table class="form-table"> |
| 1144 | <tbody> |
| 1145 | |
| 1146 | <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> |
| 1147 | |
| 1148 | <tr> |
| 1149 | |
| 1150 | <?php if ( 'textbox' === bp_get_the_profile_field_type() ) : ?> |
| 1151 | |
| 1152 | <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> |
| 1153 | <td> |
| 1154 | <input type="text" name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" value="<?php bp_the_profile_field_edit_value(); ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>/> |
| 1155 | <span class="description"><?php bp_the_profile_field_description(); ?></span> |
| 1156 | </td> |
| 1157 | |
| 1158 | <?php endif; ?> |
| 1159 | |
| 1160 | <?php if ( 'textarea' === bp_get_the_profile_field_type() ) : ?> |
| 1161 | |
| 1162 | <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> |
| 1163 | <td> |
| 1164 | <textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>><?php bp_the_profile_field_edit_value(); ?></textarea> |
| 1165 | <p class="description"><?php bp_the_profile_field_description(); ?></p> |
| 1166 | </td> |
| 1167 | |
| 1168 | <?php endif; ?> |
| 1169 | |
| 1170 | <?php if ( 'selectbox' === bp_get_the_profile_field_type() ) : ?> |
| 1171 | |
| 1172 | <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> |
| 1173 | <td> |
| 1174 | <select name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> |
| 1175 | <?php bp_the_profile_field_options(); ?> |
| 1176 | </select> |
| 1177 | <span class="description"><?php bp_the_profile_field_description(); ?></span> |
| 1178 | </td> |
| 1179 | |
| 1180 | <?php endif; ?> |
| 1181 | |
| 1182 | <?php if ( 'multiselectbox' === bp_get_the_profile_field_type() ) : ?> |
| 1183 | |
| 1184 | <th><label for="<?php bp_the_profile_field_input_name(); ?>"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label></th> |
| 1185 | <td> |
| 1186 | <select name="<?php bp_the_profile_field_input_name(); ?>" id="<?php bp_the_profile_field_input_name(); ?>" multiple="multiple" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> |
| 1187 | |
| 1188 | <?php bp_the_profile_field_options(); ?> |
| 1189 | |
| 1190 | </select> |
| 1191 | |
| 1192 | |
| 1193 | <?php if ( !bp_get_the_profile_field_is_required() ) : ?> |
| 1194 | |
| 1195 | <p><a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name(); ?>' );"><?php _e( 'Clear', 'buddypress' ); ?></a></p> |
| 1196 | |
| 1197 | <?php endif; ?> |
| 1198 | <p class="description"><?php bp_the_profile_field_description(); ?></p> |
| 1199 | </td> |
| 1200 | |
| 1201 | <?php endif; ?> |
| 1202 | |
| 1203 | <?php if ( 'radio' === bp_get_the_profile_field_type() ) : ?> |
| 1204 | |
| 1205 | <th> |
| 1206 | <span class="label"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></span> |
| 1207 | </th> |
| 1208 | <td> |
| 1209 | <fieldset> |
| 1210 | <legend class="screen-reader-text"><span><?php bp_the_profile_field_name(); ?></span></legend> |
| 1211 | <?php bp_the_profile_field_options(); ?> |
| 1212 | </fieldset> |
| 1213 | |
| 1214 | <?php if ( !bp_get_the_profile_field_is_required() ) : ?> |
| 1215 | |
| 1216 | <p><a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name(); ?>' );"><?php _e( 'Clear', 'buddypress' ); ?></a></p> |
| 1217 | |
| 1218 | <?php endif; ?> |
| 1219 | <p class="description"><?php bp_the_profile_field_description(); ?></p> |
| 1220 | </td> |
| 1221 | |
| 1222 | <?php endif; ?> |
| 1223 | |
| 1224 | <?php if ( 'checkbox' === bp_get_the_profile_field_type() ) : ?> |
| 1225 | |
| 1226 | <th> |
| 1227 | <span class="label"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></span> |
| 1228 | </th> |
| 1229 | <td> |
| 1230 | <?php bp_the_profile_field_options(); ?> |
| 1231 | <p class="description"><?php bp_the_profile_field_description(); ?></p> |
| 1232 | </td> |
| 1233 | |
| 1234 | <?php endif; ?> |
| 1235 | |
| 1236 | <?php if ( 'datebox' === bp_get_the_profile_field_type() ) : ?> |
| 1237 | |
| 1238 | <th> |
| 1239 | <label for="<?php bp_the_profile_field_input_name(); ?>_day"><?php bp_the_profile_field_name(); ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ); ?><?php endif; ?></label> |
| 1240 | </th> |
| 1241 | <td> |
| 1242 | <select name="<?php bp_the_profile_field_input_name(); ?>_day" id="<?php bp_the_profile_field_input_name(); ?>_day" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> |
| 1243 | |
| 1244 | <?php bp_the_profile_field_options( 'type=day' ); ?> |
| 1245 | |
| 1246 | </select> |
| 1247 | |
| 1248 | <select name="<?php bp_the_profile_field_input_name(); ?>_month" id="<?php bp_the_profile_field_input_name(); ?>_month" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> |
| 1249 | |
| 1250 | <?php bp_the_profile_field_options( 'type=month' ); ?> |
| 1251 | |
| 1252 | </select> |
| 1253 | |
| 1254 | <select name="<?php bp_the_profile_field_input_name(); ?>_year" id="<?php bp_the_profile_field_input_name(); ?>_year" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true"<?php endif; ?>> |
| 1255 | |
| 1256 | <?php bp_the_profile_field_options( 'type=year' ); ?> |
| 1257 | |
| 1258 | </select> |
| 1259 | <p class="description"><?php bp_the_profile_field_description(); ?></p> |
| 1260 | </td> |
| 1261 | |
| 1262 | <?php endif; ?> |
| 1263 | |
| 1264 | </tr> |
| 1265 | |
| 1266 | <?php endwhile; ?> |
| 1267 | </tbody> |
| 1268 | |
| 1269 | </table> |
| 1270 | <input type="hidden" name="field_ids[]" id="field_ids_<?php bp_the_profile_group_slug(); ?>" value="<?php bp_the_profile_group_field_ids(); ?>" /> |
| 1271 | <?php endwhile; |
| 1272 | endif; |
| 1273 | } |
| 1274 | |
| 1275 | /** |
| 1276 | * Renders the fallback metabox in case a user has been marked as a spammer. |
| 1277 | * |
| 1278 | * @access public |
| 1279 | * @since BuddyPress (?) |
| 1280 | * |
| 1281 | * @param WP_User $user The WP_User object for the user's profile to edit |
| 1282 | */ |
| 1283 | public function user_admin_spammer_metabox( $user = null ) { |
| 1284 | ?> |
| 1285 | <p><?php printf( __( '%s has been marked as a spammer, this user's BuddyPress datas were removed', 'buddypress' ), bp_core_get_user_displayname( $user->ID ) ) ;?></p> |
| 1286 | <?php |
| 1287 | } |
| 1288 | |
| 1289 | /** |
| 1290 | * Renders the Avatar metabox to moderate inappropriate images. |
| 1291 | * |
| 1292 | * @access public |
| 1293 | * @since BuddyPress (?) |
| 1294 | * |
| 1295 | * @param WP_User $user The WP_User object for the user's profile to edit |
| 1296 | */ |
| 1297 | public function user_admin_avatar_metabox( $user = null ) { |
| 1298 | |
| 1299 | if ( empty( $user->ID ) ) { |
| 1300 | return; |
| 1301 | } |
| 1302 | |
| 1303 | $args = array( |
| 1304 | 'item_id' => $user->ID, |
| 1305 | 'object' => 'user', |
| 1306 | 'type' => 'full', |
| 1307 | 'title' => $user->display_name |
| 1308 | ); |
| 1309 | |
| 1310 | ?> |
| 1311 | |
| 1312 | <div class="avatar"> |
| 1313 | |
| 1314 | <?php echo bp_core_fetch_avatar( $args ); ?> |
| 1315 | |
| 1316 | <?php if ( bp_get_user_has_avatar( $user->ID ) ) : |
| 1317 | |
| 1318 | $query_args = array( |
| 1319 | 'user_id' => $user->ID, |
| 1320 | 'action' => 'delete_avatar' |
| 1321 | ); |
| 1322 | |
| 1323 | if ( ! empty( $_REQUEST['wp_http_referer'] ) ) |
| 1324 | $query_args['wp_http_referer'] = urlencode( wp_unslash( $_REQUEST['wp_http_referer'] ) ); |
| 1325 | |
| 1326 | $community_url = add_query_arg( $query_args, $this->edit_profile_url ); |
| 1327 | $delete_link = wp_nonce_url( $community_url, 'delete_avatar' ); ?> |
| 1328 | |
| 1329 | <a href="<?php echo esc_url( $delete_link ); ?>" title="<?php _e( 'Delete Avatar', 'buddypress' ); ?>"><span class="dashicons dashicons dashicons-trash"></span> <?php _e( 'Delete Avatar', 'buddypress' ); ?></a></li> |
| 1330 | |
| 1331 | <?php endif; ?> |
| 1332 | |
| 1333 | </div> |
| 1334 | <?php |
| 1335 | } |
| 1336 | |
| 1337 | /** |
| 1338 | * Renders the Avatar metabox to moderate inappropriate images. |
| 1339 | * |
| 1340 | * @access public |
| 1341 | * @since BuddyPress (?) |
| 1342 | * |
| 1343 | * @param WP_User $user The WP_User object for the user's profile to edit |
| 1344 | */ |
| 1345 | public function user_admin_stats_metabox( $user = null ) { |
| 1346 | |
| 1347 | if ( empty( $user->ID ) ) { |
| 1348 | return; |
| 1349 | } |
| 1350 | |
| 1351 | $last_active = bp_get_user_last_activity( $user->ID ); |
| 1352 | $datef = __( 'M j, Y @ G:i', 'buddypress' ); |
| 1353 | $date = date_i18n( $datef, strtotime( $last_active ) ); ?> |
| 1354 | |
| 1355 | <ul> |
| 1356 | <li><div class="dashicons dashicons-last-active"></div> <?php printf( __( 'Last active: <strong>%1$s</strong>', 'buddypress' ), $date ); ?></li> |
| 1357 | <?php if ( bp_is_active( 'friends' ) && $friends_amount = friends_get_total_friend_count( $user->ID ) ) : ?> |
| 1358 | <li><div class="dashicons dashicons-friends"></div> <?php printf( _n( '1 friend', '<strong>%s</strong> friends', $friends_amount, 'buddypress' ), $friends_amount );?></li> |
| 1359 | <?php endif; |
| 1360 | |
| 1361 | if ( bp_is_active( 'groups' ) && $groups_amount = bp_get_total_group_count_for_user( $user->ID ) ) : ?> |
| 1362 | <li><div class="dashicons dashicons-groups"></div> <?php printf( _n( '1 group', '<strong>%s</strong> groups', $groups_amount, 'buddypress' ), $groups_amount );?></li> |
| 1363 | <?php endif; |
| 1364 | |
| 1365 | if ( bp_is_active( 'blogs' ) && is_multisite() && $blogs_amount = bp_blogs_total_blogs_for_user( $user->ID ) ) : ?> |
| 1366 | <li><div class="dashicons dashicons-blogs"></div> <?php printf( _n( '1 site', '<strong>%s</strong> sites', $blogs_amount, 'buddypress' ), $blogs_amount );?></li> |
| 1367 | <?php endif; |
| 1368 | |
| 1369 | // Plugins may add their custom stats here... |
| 1370 | do_action( 'bp_xprofile_user_admin_stats', $user->ID, $user ); |
| 1371 | ?> |
| 1372 | </ul> |
| 1373 | <?php |
| 1374 | } |
| 1375 | |
| 1376 | /** |
| 1377 | * Adds a link to user's profile in users listing row actions. |
| 1378 | * |
| 1379 | * @access public |
| 1380 | * @since BuddyPress (?) |
| 1381 | * |
| 1382 | * @param array $actions the WordPress row actions (edit, delete) |
| 1383 | * @param object $user The object for the user's row |
| 1384 | */ |
| 1385 | public function row_actions( $actions = '', $user = null ) { |
| 1386 | |
| 1387 | if ( get_current_user_id() === $user->ID ) { |
| 1388 | return $actions; |
| 1389 | } |
| 1390 | |
| 1391 | $edit_xprofile = add_query_arg( array( |
| 1392 | 'user_id' => $user->ID, |
| 1393 | 'wp_http_referer' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) |
| 1394 | ), $this->edit_profile_url ); |
| 1395 | |
| 1396 | $edit_action = $actions['edit']; |
| 1397 | unset( $actions['edit'] ); |
| 1398 | |
| 1399 | $new_edit_actions = array( |
| 1400 | 'edit' => $edit_action, |
| 1401 | 'edit-xprofile' => '<a href="' . esc_url( $edit_xprofile ) . '">' . __( 'Profile', 'buddypress' ) . '</a>' |
| 1402 | ); |
| 1403 | |
| 1404 | return array_merge( $new_edit_actions, $actions ); |
| 1405 | } |
| 1406 | } |
| 1407 | |
| 1408 | endif; // class_exists check |
| 1409 | |
| 1410 | /** |
| 1411 | * Setup xProfile User Admin. |
| 1412 | * |
| 1413 | * @since BuddyPress (?) |
| 1414 | * |
| 1415 | * @uses buddypress() to get BuddyPress main instance |
| 1416 | */ |
| 1417 | function xprofile_user_admin() { |
| 1418 | buddypress()->admin->xprofile = new BP_XProfile_User_Admin(); |
| 1419 | } |
| 1420 | |
| 1421 | // Load the xprofile user admin |
| 1422 | if ( is_admin() ) { |
| 1423 | add_action( 'bp_loaded', 'xprofile_user_admin', 11 ); |
| 1424 | } |