How to delete user on logout and when session expires?

So this is what I did…also keep in mind this is for a multisite and I am call calling this within a class. ‘Client’ is a custom user role that is create and given to users when they are created. function delete_user() { global $current_user; if(in_array(‘client’, $current_user->roles )){ if(!function_exists(‘wp_delete_user’)) { include(ABSPATH . “wp-admin/includes/ms.php”); } wpmu_delete_user( … Read more

Add ‘Creator’ User Meta when adding user

//Whenever a user will be created ‘user_register’ hook of WordPress is executed add_action( ‘user_register’, ‘meta_registration_save’, 10, 1 ); //Following function will be called on each user registration and will save the ‘created_by’ information in wp_usermeta table function meta_registration_save( $user_id ) { //logged in user if ( is_user_logged_in() ) { global $current_user; get_currentuserinfo(); $current_id=$current_user->ID; add_user_meta( $user_id, … Read more

Restrict users post for himself

Try this code: (edited code a little) add_action( ‘template_redirect’, ‘my_page_template_redirect’ ); function my_page_template_redirect() { global $post; if( is_user_logged_in() ) { if( is_single() ){ if( $post->post_author != get_current_user_id() ){ wp_redirect( ‘IN ANY PAGE’ ); } } }else{ wp_redirect( ‘IN ANY PAGE’ ); } }