The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End PHP/WP – Apply function result to an object’s property

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #29839

    That tile probably makes no sense. Sorry.

    What I’m doing: I’m using Chris’ Wufoo plugin to create a WP plugin. I have an options page setup in WP where I can store a username/subdomain, API Key, and Form Hash (just to start). I can get those options very easily with the get_option(); function.

    What I cannot figure out how to do is apply the sql results from the getUsername and getApiKey functions to their respective variables and then pass them to the WufooGetter class and corresponding object.

    Here’s the code for each class.

    class jQueryConfig {

    public $username;
    public $api_key;

    public function getUsername() {
    global $wpdb;

    $sql = $wpdb->get_row(“SELECT * FROM $wpdb->options WHERE option_name = ‘w4wp_username'”);
    $this->username = $sql->option_value;

    return $this->$username;

    public function getApiKey() {
    global $wpdb;

    $query = $wpdb->get_row(“SELECT * FROM $wpdb->options WHERE option_name = ‘w4wp_api_key'”);
    return $this->api_key = $query->option_value;

    class WufooGetter {

    private $url;
    private $config;

    public function __construct($url, $config) {
    $this->url = $url;
    $this->config = $config;

    public function makeCall() {

    $curl = curl_init(‘https://’.$this->config->subdomain.’’.$this->url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_USERPWD, $this->config->apiKey.’:footastic’);
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_USERAGENT, ‘Wufoo Sample Code’);

    $response = curl_exec($curl);
    $resultStatus = curl_getinfo($curl);

    if ($resultStatus[‘http_code’] == 200) {
    echo $response;
    } else {
    echo ‘Call Failed ‘.print_r($resultStatus);

    $wufooGetter = new WufooGetter($_GET[‘url’], new jQueryConfig());

    And here’s the link to the jQuery Plugin on Git Hub

    Any advice is greatly appreciated!



    AS far as I know this is the formal documentation of WP_Query. You shouldn’t alter the properties directly, but instead use the methods to interact with them. And Gets filled with the requested posts from the database.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.