bp_core_admin_user_row_actions

Add "Mark as Spam/Ham" button to user row actions.

Description

(array) bp_core_admin_user_row_actions( (array) $actions, (object) $user_object ); 

Returns (array)

$actions User row action links.

Parameters (2)

0. $actions (array)
User row action links.
1. $user_object (object)
Current user information.

Usage

  1. if ( !function_exists( 'bp_core_admin_user_row_actions' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/admin/bp-core-admin-functions.php'; 
  3.  
  4. // User row action links. 
  5. $actions = array(); 
  6.  
  7. // Current user information. 
  8. $user_object = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_core_admin_user_row_actions($actions, $user_object); 
  12.  

Defined (1)

The function is defined in the following location(s).

/bp-core/admin/bp-core-admin-functions.php  
  1. function bp_core_admin_user_row_actions( $actions, $user_object ) { 
  2.  
  3. // Setup the $user_id variable from the current user object. 
  4. $user_id = 0; 
  5. if ( !empty( $user_object->ID ) ) { 
  6. $user_id = absint( $user_object->ID ); 
  7.  
  8. // Bail early if user cannot perform this action, or is looking at themselves. 
  9. if ( current_user_can( 'edit_user', $user_id ) && ( bp_loggedin_user_id() !== $user_id ) ) { 
  10.  
  11. // Admin URL could be single site or network. 
  12. $url = bp_get_admin_url( 'users.php' ); 
  13.  
  14. // If spammed, create unspam link. 
  15. if ( bp_is_user_spammer( $user_id ) ) { 
  16. $url = add_query_arg( array( 'action' => 'ham', 'user' => $user_id ), $url ); 
  17. $unspam_link = wp_nonce_url( $url, 'bp-spam-user' ); 
  18. $actions['ham'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $unspam_link ), esc_html__( 'Not Spam', buddypress ) ); 
  19.  
  20. // If not already spammed, create spam link. 
  21. } else { 
  22. $url = add_query_arg( array( 'action' => 'spam', 'user' => $user_id ), $url ); 
  23. $spam_link = wp_nonce_url( $url, 'bp-spam-user' ); 
  24. $actions['spam'] = sprintf( '<a class="submitdelete" href="%1$s">%2$s</a>', esc_url( $spam_link ), esc_html__( 'Spam', buddypress ) ); 
  25.  
  26. // Create a "View" link. 
  27. $url = bp_core_get_user_domain( $user_id ); 
  28. $actions['view'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $url ), esc_html__( 'View', buddypress ) ); 
  29.  
  30. // Return new actions. 
  31. return $actions;