WordPress.org

Ready to get started?Download WordPress

Forums

[closed] [Plugin: SS Quiz] Need to get the Post ID inside functions.php (2 posts)

  1. Mike Rodriguez
    Member
    Posted 8 months ago #

    I've been at this issue for HOURS now. I need some help or a push in the right direction at least, because I'm stumped.

    Issue: I need to get the post ID inside functions.php

    I'm using a plugin called SS Quiz. This plugin is a quiz making plugin, in which you make a quiz on the backend and display it using shortcodes inside your WP WYSIWYG editot. Simple, just like lots of plugins out there.

    SS Quiz has a hook in which once the quiz is submitted, it will excute a block of code. Below is the exact code and documentation:

    add_action('ssquiz_finished', 'after_quiz_done', 10, 4);
    
    function after_quiz_done( $quiz_id, $user_id, $questions_right, $total_questions )
    {
    	// do stuff here
    }

    hook is triggered when SSQuiz is finished by the user

    What i'm trying to do is get the post id of the current post/page in which the quiz is on, and execute a block of code simply returns the post id. I've tried everything from using the global $post to setting up postdata(setup_postdata()) inside the function. Nothing has worked. I can return thing like current logged in user, but simply not the post id.

    Can anyone test this on their end and see how they can get the post ID? Whether it be on a live server or locally. I just need a push in the right direction at this point.

    ANY help would be greatly appreciated!

  2. esmi
    Forum Moderator
    Posted 8 months ago #

Topic Closed

This topic has been closed to new replies.

About this Topic