entoen

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • in reply to: assign user role on submitting listing #528296

    entoen
    Free User
    Post count: 6

    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 );
    in reply to: assign user role on submitting listing #528295

    entoen
    Free User
    Post count: 6

    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 );
    in reply to: assign user role on submitting listing #528201

    entoen
    Free User
    Post count: 6

    Any idea’s anybody?

    in reply to: assign user role on submitting listing #525850

    entoen
    Free User
    Post count: 6

    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

    in reply to: Cant load CSV #520372

    entoen
    Free User
    Post count: 6

    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?

Viewing 5 posts - 1 through 5 (of 5 total)
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount