Skip to content

[Resolved] Wrong WHERE clause in ajax request

Home Forums Obsolete: 2.0 beta Wrong WHERE clause in ajax request

This topic contains 1 reply, has 2 voices, and was last updated by 5 years, 4 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #16366

    Hi Kevin,

    I have a function that by ajax call that returns the contents of a page to show in modal, is to show the legal notice in the contact form.

    function get_only_content () {
    check_ajax_referer('get_only_content_nonce', 'security_nonce');
    if(isset($_REQUEST['ajax_page']) && $_REQUEST['ajax_page'] != '') {
    $args = array(
    'post_type' => 'page',
    'name' => $_REQUEST['ajax_page']
    );
    $query = new WP_Query( $args );
    // The Loop
    while ( $query->have_posts() ) :
    $query->the_post();
    the_content();
    endwhile;
    wp_reset_postdata();
    }
    die();
    }

     

    If I call the function with Admin user, work well, the query is the following:

    SELECT DISTINCT wp_posts.* FROM wp_posts  WHERE 1=1 AND wp_posts.post_name = ‘avis-legal’ AND wp_posts.post_type = ‘page’  ORDER BY wp_posts.post_date DESC

    Otherwise:

    SELECT  DISTINCT wp_posts.* FROM wp_posts  WHERE 1=1   AND (  ( wp_posts.post_type = ‘page’ AND 1=2 )  )  AND wp_posts.post_name = ‘avis-legal’ AND wp_posts.post_type = ‘page’  ORDER BY wp_posts.post_date DESC 

     

    The page is visible for all groups, and all roles.

     

    Regards,

    Jordi Favà.

    #16372

    [ login required ]

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

The forum ‘Obsolete: 2.0 beta’ is closed to new topics and replies.

Registered members have full access to Pro support forums here.

Feel free to log in or purchase a support key.