Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Display Xenforo field in WordPress

$
0
0

Replies: 0

Hi All

So i have a simple script that takes the username from xenforo (when you are logged in) and displays it as HTML. This is the script.

<?php

$startTime = microtime(true);
$fileDir = 'C:\Domains\xxxxx.com\httpdocs\forums';

require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');

XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);

XenForo_Session::startPublicSession();

$visitor = XenForo_Visitor::getInstance()->toArray();
?>

That is saved as a file called “xf_connector.php”

The code to display the username is this.

<?php
require 'xf_connector.php';
?>
<!DOCTYPE html>
<html>
    <head>
<title>My first page</title>
<meta charset="UTF-8">
    </head>
<body>
<p>Hello <?php $xf_userId = $visitor['user_id'];
$xf_username = $visitor['username'];
echo "$xf_username" ?> welcome to this web page.</p>

</body>
</html>

The problems im having at the moment is displaying that anywhere on a wordpress site. The 2nd problem will be that i want it to appear on a couple of product’s using woocommerce, not all of my products so i have installed a plugin that gives products of my choosing custom fields, however they are only plain text boxes’ not the option to use and code etc.

Any help please?

Thanks
Mat


Viewing all articles
Browse latest Browse all 59525

Trending Articles