Home Forums Plugin Support WP User Frontend Pro Error counter

This topic is: resolved

Tagged: 

This topic contains 10 replies, has 3 voices, and was last updated by  david 5 years, 6 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #9848

    david
    Participant
    Post count: 40

    HI,

    On the desktop, the counter posts gives me error.
    If I have created two posts and then I eliminate the two posts, the counter should again be two (Post Left: 2), but not, the counter stays at zero (Post Left: 0) and I can not create a new post (You must purchase a pack before posting). The subscription package is for one year but the elimination of the post should make up the counter, in this case is not that.

    Thanks,
    David

    #9854

    Mahi
    Member
    Post count: 1555

    Hello David,

    Thats why “Edit” option comes! If user not happy with the post then they can edit that.

    Post deleting not going to increate post limit again. Cause, user already posted what they paid for! Isn't it?

    If you need to edit user's post limit you have to do that manually.

    Go to their profile from admin area -> WPUF Subscription -> Post Count:

    #9869

    david
    Participant
    Post count: 40

    Hello Mahi,

    I think this is not correct. The user pays for a number of posts within a certain date and he can edit and delete posts as often as he wants. The counter should reflect these changes.

    The easy example, if the user has ordered 3 posts and he created all three, if he removes one post, the counter should be in 2, the user still has the possibility of creating a new post.

    This is possible?

    Thanks!

    #9927

    david
    Participant
    Post count: 40

    Is there anyone who can answer that?
    Is very important for me.

    Thanks.
    David

    #9930

    Tareq Hasan
    Keymaster
    Post count: 2831

    WPUF doesn't do any sort of increasing count once a post is deleted. But if you think you need this feature, here is the code may be you could use. Paste it to your themes functions.php and see if it solves your problem.

    [php]
    /**
    * Increase the post count once a post is deleted
    *
    * @param int $post_id
    */
    function wpufe_trash_post( $post_id ) {
    // bail out if charging is not enabled
    if ( wpuf_get_option( ‘charge_posting', ‘wpuf_payment' ) != ‘yes' ) {
    return false;
    }

    $author_id = get_post_field( ‘post_author', $post_id );
    $userdata = get_userdata( $author_id );

    $count = ( $userdata->wpuf_sub_pcount ) ? $userdata->wpuf_sub_pcount : 0;
    if ( $count != ‘unlimited' ) {
    $count = intval( $count );
    update_user_meta( $userdata->ID, ‘wpuf_sub_pcount', $count + 1 );
    }
    }

    add_action( ‘wp_trash_post', ‘wpufe_trash_post' );
    [/php]

    #9939

    david
    Participant
    Post count: 40

    Thank you very much, that is a very important part for my project.

    The code works but partially. For example, if the user has a limit of 3 post, if he writes two posts and then deletes one or two posts, this works perfectly, the counter reflect these changes. But if you write three posts (3 of 3), there is a error: the counter no reflect these changes, remains at 0 even remove the three posts and the user can not create a post.

    Thanks.
    David

    #9960

    Tareq Hasan
    Keymaster
    Post count: 2831

    So you are saying, if he write 3 posts and then deletes 1 or 2 posts, it doesn't increase the limit?

    #9973

    david
    Participant
    Post count: 40

    An example: The limit is 3 posts. If I write 1 or 2 posts and then delete 1 or 2 posts, the limit increases. This is perfect. The error is if I write 3 posts (the limit is 3), then the counter is at zero and I can not write more posts. If I delete all posts, the counter also continues to zero.

    Thanks!

    #10014

    david
    Participant
    Post count: 40

    Tareq, can you help me with this, please?
    Thank you.

    #10117

    Tareq Hasan
    Keymaster
    Post count: 2831

    In the code, replace $count != 'unlimited' with $count !== 'unlimited' and see if it solves your problem.

    #10210

    david
    Participant
    Post count: 40

    It works perfectly!!

    Thank you very much!
    David

Viewing 11 posts - 1 through 11 (of 11 total)

The topic ‘Error counter’ is closed to new replies.