WordPress.org

Ready to get started?Download WordPress

Forums

Namaste! LMS
[resolved] How to Restrict User Visit on Lesson? (4 posts)

  1. sanketzalak
    Member
    Posted 10 months ago #

    I want to Restrict Users to Total Visit Per Lesson 5 Times?

    How can I do that?

    With This WP Query, I can get the Total Visits.
    $myset = $wpdb->get_results( "SELECT visits FROM wp_namaste_visitsWHEREuser_id='$u_id' ANDlesson_id='$postid'" );

    with 'echo print_r($myset);'

    Output is as Require.

    Array
    (
        [0] => stdClass Object
            (
                [visits] => 1
            )
    
        [1] => stdClass Object
            (
                [visits] => 7
            )
    
        [2] => stdClass Object
            (
                [visits] => 62
            )
    
    )

    Now What I can't Solve is How to Sum - All Values Got from Query?

    If (sum of visits <= 5)
    			{
    			// Do This
    			|
    			else
    			{
    			//
    			}
    		}

    http://wordpress.org/plugins/namaste-lms/

  2. prasunsen
    Member
    Plugin Author

    Posted 10 months ago #

    There is one record for each date, so you need a SUM() query.

  3. sanketzalak
    Member
    Posted 10 months ago #

    May Be it's what I look for, My Basic Requirement is to Check that if User have access the lesson less than five times if condition triggers.

    Or if User have access the lesson more than five times else part of condition will be triggered.

    No Matter for How Many Days user takes.

    Thanks

  4. sanketzalak
    Member
    Posted 10 months ago #

    @prasunsen : Ok, Sir the Query is Solved as per Your Suggestion.

    Thanks . . . .

Reply

You must log in to post.

About this Plugin

About this Topic