Skip to content

Instantly share code, notes, and snippets.

View KuldeepSJadon's full-sized avatar
🎯
Focusing

Kuldeep Singh Jadon KuldeepSJadon

🎯
Focusing
  • Jodhpur, India
View GitHub Profile
@kimwhite
kimwhite / pmpro_after_change_author_level_update_posts.php
Last active September 27, 2021 17:44 — forked from strangerstudios/pmpro_after_change_author_level_update_posts.php
Unpublish an author's posts or cpt when their membership is cancelled.
<?php function pmpro_after_change_author_level_update_posts( $level_id, $user_id ) {
//get the user roles
$usermeta = get_userdata($user_id);
$user_roles = $usermeta->roles;
//check if the user is an author and is cancelling
if ( in_array( 'author', $user_roles ) && $level_id == 0 ) {
//get the user's posts
$args = array(
'author' => $user_id,