• Resolved bojorquezja

    (@bojorquezja)


    Hello,

    I like your poll very much, great work. I have a question, i need to know from which post the people is voting but when i try to use:

    global $post;
    $id = $post->ID; —- returns null

    global $wp_query
    $id =$wp_query->get_queried_object_id(); –return 0

    global $wp_query;
    echo $wp_query->post->ID; –return null

    I’m, calling those functions from inside the “register_vote” function.
    I would apreciate your help. Thanks in advance.

    https://wordpress.org/plugins/yop-poll/

Viewing 1 replies (of 1 total)
  • Thread Starter bojorquezja

    (@bojorquezja)

    I solve it myself. Inside the code you use javascript and php so you have to:
    1.- in return_yop_poll (public-admin.php) save the $post->ID in a variable
    2.- pass the value through arrays in php and javascript using functions like:
    return_yop_poll (public-admin.php), return_poll_html (poll_model.php), yop_poll_register_vote (yoll-poll-public.js), yop_poll_do_vote (admin.php), and others to get finally to register_vote (poll_model.php) and use a validation here.

    Inside this last function the $post->ID doesn’t work because the url ends in wp-admin\ajax so the only way is to pass the post ID as a variable.

Viewing 1 replies (of 1 total)
  • The topic ‘Know the post ID of a custom post type from inside the poll’ is closed to new replies.