BP_Members_Admin::user_admin_load()
Set up the user’s profile admin page.
Description
Loaded before the page is rendered, this function does all initial setup, including: processing form requests, registering contextual help, and setting up screen options.
Source
File: bp-members/classes/class-bp-members-admin.php
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 | public function user_admin_load() { // Get the user ID. $user_id = $this ->get_user_id(); // Can current user edit this profile? if ( ! $this ->member_can_edit( $user_id ) ) { wp_die( __( 'You cannot edit the requested user.' , 'buddyboss' ) ); } // Build redirection URL. $redirect_to = remove_query_arg( array ( 'action' , 'error' , 'updated' , 'spam' , 'ham' , 'delete_avatar' ), $_SERVER [ 'REQUEST_URI' ] ); $doaction = ! empty ( $_REQUEST [ 'action' ] ) ? $_REQUEST [ 'action' ] : false; if ( ! empty ( $_REQUEST [ 'user_status' ] ) ) { $spam = (bool) ( 'spam' === $_REQUEST [ 'user_status' ] ); if ( $spam !== bp_is_user_spammer( $user_id ) ) { $doaction = $_REQUEST [ 'user_status' ]; } } /** * Fires at the start of the signups admin load. * * @since BuddyPress 2.0.0 * * @param string $doaction Current bulk action being processed. * @param array $_REQUEST Current $_REQUEST global. */ do_action_ref_array( 'bp_members_admin_load' , array ( $doaction , $_REQUEST ) ); /** * Filters the allowed actions for use in the user admin page. * * @since BuddyPress 2.0.0 * * @param array $value Array of allowed actions to use. */ $allowed_actions = apply_filters( 'bp_members_admin_allowed_actions' , array ( 'update' , 'delete_avatar' , 'spam' , 'ham' ) ); // Prepare the display of the Community Profile screen. if ( ! in_array( $doaction , $allowed_actions ) ) { add_screen_option( 'layout_columns' , array ( 'default' => 2, 'max' => 2, ) ); get_current_screen()->add_help_tab( array ( 'id' => 'bp-profile-edit-overview' , 'title' => __( 'Overview' , 'buddyboss' ), 'content' => '<p>' . __( 'This is the admin view of a user\'s profile.' , 'buddyboss' ) . '</p>' . '<p>' . __( 'In the main column, you can edit the fields of the user\'s extended profile.' , 'buddyboss' ) . '</p>' . '<p>' . __( 'In the right-hand column, you can update the user\'s status, delete the user\'s avatar, and view recent statistics.' , 'buddyboss' ) . '</p>' ) ); // Help panel - sidebar links. get_current_screen()->set_help_sidebar( '<p><strong>' . __( 'For more information:' , 'buddyboss' ) . '</strong></p>' . '<p>' . __( '<a href="https://www.buddyboss.com/resources/">Documentation</a>' , 'buddyboss' ) . '</p>' ); // Register metaboxes for the edit screen. add_meta_box( 'submitdiv' , __( 'Status' , 'buddyboss' ), array ( $this , 'user_admin_status_metabox' ), get_current_screen()->id, 'side' , 'core' ); // In case xprofile is not active. $this ->stats_metabox->context = 'normal' ; $this ->stats_metabox->priority = 'core' ; /** * Fires before loading the profile fields if component is active. * * Plugins should not use this hook, please use 'bp_members_admin_user_metaboxes' instead. * * @since BuddyPress 2.0.0 * * @param int $user_id Current user ID for the screen. * @param string $id Current screen ID. * @param object $stats_metabox Object holding position data for use with the stats metabox. */ do_action_ref_array( 'bp_members_admin_xprofile_metabox' , array ( $user_id , get_current_screen()->id, $this ->stats_metabox ) ); // If xProfile is inactive, difficult to know what's profile we're on. if ( 'normal' === $this ->stats_metabox->context ) { $display_name = bp_core_get_user_displayname( $user_id ); } else { $display_name = __( 'Member' , 'buddyboss' ); } // User Stat metabox. add_meta_box( 'bp_members_admin_user_stats' , sprintf( __( "%s's Stats" , 'buddyboss' ), $display_name ), array ( $this , 'user_admin_stats_metabox' ), get_current_screen()->id, sanitize_key( $this ->stats_metabox->context ), sanitize_key( $this ->stats_metabox->priority ) ); // profile type metabox. Only added if profile types have been registered. $member_types = bp_get_member_types(); if ( ! empty ( $member_types ) ) { add_meta_box( 'bp_members_admin_member_type' , __( 'Profile Type' , 'buddyboss' ), array ( $this , 'user_admin_member_type_metabox' ), get_current_screen()->id, 'side' , 'core' ); } /** * Fires at the end of the Community Profile screen. * * Plugins can restrict metabox to "bp_moderate" admins by checking if * the first argument ($this->is_self_profile) is false in their callback. * They can also restrict their metabox to self profile editing * by setting it to true. * * @since BuddyPress 2.0.0 * * @param bool $is_self_profile Whether or not it is the current user's profile. * @param int $user_id Current user ID. */ do_action( 'bp_members_admin_user_metaboxes' , $this ->is_self_profile, $user_id ); // Enqueue JavaScript files. wp_enqueue_script( 'postbox' ); wp_enqueue_script( 'dashboard' ); // Spam or Ham user. } elseif ( in_array( $doaction , array ( 'spam' , 'ham' ) ) && empty ( $this ->is_self_profile ) ) { check_admin_referer( 'edit-bp-profile_' . $user_id ); if ( bp_core_process_spammer_status( $user_id , $doaction ) ) { $redirect_to = add_query_arg( 'updated' , $doaction , $redirect_to ); } else { $redirect_to = add_query_arg( 'error' , $doaction , $redirect_to ); } bp_core_redirect( $redirect_to ); // Update other stuff once above ones are done. } else { $this ->redirect = $redirect_to ; /** * Fires at end of user profile admin load if doaction does not match any available actions. * * @since BuddyPress 2.0.0 * * @param string $doaction Current bulk action being processed. * @param int $user_id Current user ID. * @param array $_REQUEST Current $_REQUEST global. * @param string $redirect Determined redirect url to send user to. */ do_action_ref_array( 'bp_members_admin_update_user' , array ( $doaction , $user_id , $_REQUEST , $this ->redirect ) ); bp_core_redirect( $this ->redirect ); } } |
Changelog
Version | Description |
---|---|
BuddyPress 2.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.