um_admin_delete_role_cache

The Ultimate Member um admin delete role cache function.

Description

um_admin_delete_role_cache( $post_id, $post ); 

Parameters (2)

0. $post_id
The post id.
1. $post
The post.

Usage

  1. if ( !function_exists( 'um_admin_delete_role_cache' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ultimate-member/admin/core/um-admin-actions.php'; 
  3.  
  4. // The post id. 
  5. $post_id = null; 
  6.  
  7. // The post. 
  8. $post = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = um_admin_delete_role_cache($post_id, $post); 
  12.  

Defined (1)

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

/admin/core/um-admin-actions.php  
  1. function um_admin_delete_role_cache($post_id, $post) { 
  2. global $wpdb, $ultimatemember; 
  3. if( get_post_type( $post_id ) == 'um_role') { 
  4. $slug = $post->post_name; 
  5.  
  6. $is_core = get_post_meta( $post_id, '_um_core', true ); 
  7. if ( $is_core == 'member' || $is_core == 'admin' ) { 
  8. $slug = $is_core; 
  9. $where = array( 'ID' => $post_id ); 
  10. $wpdb->update( $wpdb->posts, array( 'post_name' => $slug ), $where ); 
  11.  
  12. delete_option("um_cached_role_{$slug}"); 
  13.  
  14. // need to remove cache of all users 
  15. $users = get_users( array( 'fields' => array( 'ID' ), 'meta_key' => 'role', 'meta_value' => $slug ) ); 
  16. foreach( $users as $user ) { 
  17. $ultimatemember->user->remove_cache( $user->ID );