entoen
Forum Replies Created
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
got it!
cannot use $post_count = 0
so i turned to the expired listings; this works fine:
/*change user role when MORE then xxx posts on login*/
function custom_update_roles( $user_login, $user ) {
if ( ! empty( $user->roles ) && is_array( $user->roles ) ) {
if ( in_array( "author", $user->roles ) )
{
$user_id =$user->ID;
$post_count=count_user_posts( $user_id,'gd_place' )->expire;
if ( $post_count = 1 ) {
// Success.
$u = new WP_User( $user_id );
$u->remove_role( 'author' );
$u->add_role( 'subscriber' );
}
}
else
{
// This user is not a subscriber.
}
}
}
add_action( 'wp_login', 'custom_update_roles', 10, 2 );
I thought so too, and it is working!
one last adjustment i cannot seem to implement is that i only want the published post to be counted. Is that possible?
I tried adding “->publish” but it doesn’t do the job:
function custom_update_roles( $user_login, $user ) {
if ( ! empty( $user->roles ) && is_array( $user->roles ) ) {
if ( in_array( "author", $user->roles ) )
{
$user_id =$user->ID;
$post_count=count_user_posts( $user_id,'gd_place' )->publish;
if ( $post_count = 0 ) {
// Success.
$u = new WP_User( $user_id );
$u->remove_role( 'author' );
$u->add_role( 'subscriber' );
}
}
else
{
// This user is not a subscriber.
}
}
}
add_action( 'wp_login', 'custom_update_roles', 10, 2 );
Any idea’s anybody?
hi Stiofan, thank you for your answer. It isn’t working. Why would checking for post types work? I am only using gd_place as a post-type.
Han
your system is not very user friendly. How do I enter multiple images in your .csv file? I exported an existing one, changed something and saved it. Then it keeps saying it is the wrong csv-format. Now what?
Get the latest news, tips, and exclusive content directly in your inbox.
Confirm your email address, and instantly receive the discount code :)