bp_core_admin_user_row_actions( array $actions, object $user_object )
Add “Mark as Spam/Ham” button to user row actions.
Description
Parameters
- $actions
-
(Required) User row action links.
- $user_object
-
(Required) Current user information.
Return
(array) $actions User row action links.
Source
File: bp-core/admin/bp-core-admin-functions.php
1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 | function bp_core_admin_user_row_actions( $actions , $user_object ) { // Setup the $user_id variable from the current user object. $user_id = 0; if ( ! empty ( $user_object ->ID ) ) { $user_id = absint( $user_object ->ID ); } // Bail early if user cannot perform this action, or is looking at themselves. if ( current_user_can( 'edit_user' , $user_id ) && ( bp_loggedin_user_id() !== $user_id ) ) { // Admin URL could be single site or network. $url = bp_get_admin_url( 'users.php' ); // If spammed, create unspam link. if ( bp_is_user_spammer( $user_id ) ) { $url = add_query_arg( array ( 'action' => 'ham' , 'user' => $user_id ), $url ); $unspam_link = wp_nonce_url( $url , 'bp-spam-user' ); $actions [ 'ham' ] = sprintf( '<a href="%1$s">%2$s</a>' , esc_url( $unspam_link ), esc_html__( 'Not Spam' , 'buddyboss' ) ); // If not already spammed, create spam link. } else { $url = add_query_arg( array ( 'action' => 'spam' , 'user' => $user_id ), $url ); $spam_link = wp_nonce_url( $url , 'bp-spam-user' ); $actions [ 'spam' ] = sprintf( '<a class="submitdelete" href="%1$s">%2$s</a>' , esc_url( $spam_link ), esc_html__( 'Spam' , 'buddyboss' ) ); } } // Create a "View" link. $url = bp_core_get_user_domain( $user_id ); $actions [ 'view' ] = sprintf( '<a href="%1$s">%2$s</a>' , esc_url( $url ), esc_html__( 'View' , 'buddyboss' ) ); // Return new 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.