BP_Members_Admin::row_actions( array|string $actions = '', object|null $user = null )
Add a link to Profile in Users listing row actions.
Description
Parameters
- $actions
-
(Optional) WordPress row actions (edit, delete).
Default value: ''
- $user
-
(Optional) The object for the user row.
Default value: null
Return
(null|string|array) Merged actions.
Source
File: bp-members/classes/class-bp-members-admin.php
public function row_actions( $actions = '', $user = null ) {
// Bail if no user ID.
if ( empty( $user->ID ) ) {
return;
}
// Setup args array.
$args = array();
// Add the user ID if it's not for the current user.
if ( $user->ID !== $this->current_user_id ) {
$args['user_id'] = $user->ID;
}
// Add the referer.
$wp_http_referer = wp_unslash( $_SERVER['REQUEST_URI'] );
$wp_http_referer = wp_validate_redirect( esc_url_raw( $wp_http_referer ) );
$args['wp_http_referer'] = urlencode( $wp_http_referer );
// Add the "Extended" link if the current user can edit this user.
if ( current_user_can( 'edit_user', $user->ID ) || bp_current_user_can( 'bp_moderate' ) ) {
// Add query args and setup the Extended link.
$edit_profile = add_query_arg( $args, $this->edit_profile_url );
$edit_profile_link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $edit_profile ), esc_html__( 'Extended', 'buddyboss' ) );
/**
* Check the edit action is available
* and preserve the order edit | profile | remove/delete.
*/
if ( ! empty( $actions['edit'] ) ) {
$edit_action = $actions['edit'];
unset( $actions['edit'] );
$new_edit_actions = array(
'edit' => $edit_action,
'edit-profile' => $edit_profile_link,
);
// If not available simply add the edit profile action.
} else {
$new_edit_actions = array( 'edit-profile' => $edit_profile_link );
}
$actions = array_merge( $new_edit_actions, $actions );
}
return $actions;
}
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.