• Welcome to the all-new Kolakube support, the official place to get help for Marketers Delight, XFtoWP, CryptoWP, and other WordPress products! Please login with your account details to access members-only support forums.

API and polls

Rush

Active member
XFtoWP
Messages
71
Reaction score
9
I have been taking a look at the API data and one of the things we are wanting to attempt is to grab the poll data from a thread set as a poll.

$thread_id = xf_post_meta( array( 'comments', 'thread_id' ) );
print_r( $thread_id);

works fine to get the thread id and I can spit out the first post data fine also but I am not sure where the poll data is and the XF docs are a little vague on this. Is there a way to grab that poll data easily with XFWP active?
 
Very timely thread, I am working on a side project to make it possible to display and vote for polls with XFtoWP. :D No release date but glad we share the same curiosity.

Yes, you can easily get Poll data like so from a custom request:

PHP:
$request = xf_request( 'GET', 'threads/400' );
print_r( $request->thread->Poll );

400 = the thread ID, of course.
 
Comment
This is what I tried....

$thread_id = xf_post_meta( array( 'comments', 'thread_id' ) );
$request = xf_request( 'GET', 'threads/$thread_id' );
print_r( $request->thread->Poll );

Annoyingly it doesn't work. ends up with Undefined property: stdClass::$thread.
 
Comment
This is what I tried....

$thread_id = xf_post_meta( array( 'comments', 'thread_id' ) );
$request = xf_request( 'GET', 'threads/$thread_id' );
print_r( $request->thread->Poll );

Annoyingly it doesn't work. ends up with Undefined property: stdClass::$thread.
You have to use double quotes if you are including a variable in the string.

PHP:
$request = xf_request( 'GET', "threads/$thread_id" );
 
Comment
Back
Top