This topic is locked

Wordpress 4.x and PHPRunner 8.x

6/12/2015 12:55:40 PM
PHPRunner Tips and Tricks
admin

Here is the updated Wordpress tutorial. We have tested it with Wordpress 4.2.2 and PHPRunner 8.0.

This tutorial assumes that Wordpress and PHPRunner project are located on the same level of web server hierarchy. In our example Wordpress is installed to http://localhost/wordpress and PHPRunner app is installed to http://localhost/phprunner. You will have to adjust the path to Wordpress folder if your setup is different.

If everything is setup properly users logged in to Wordpress will be logged in to PHPRunner application as well. If you do not need this functionality or your PHPRunner project doesn't use security you can skip step 2 and 3.

1. Install and activate embed-iframe Wordpress plugin

This plugin allows to insert an iframe into any post.

2. Modify Wordpress's wp-config.php file adding the lines in bold:

define('WP_DEBUG', false);
define('COOKIEPATH', "/" );

This allows to share Wordpress cookies across the whole website.

3. AfterAppInit event of PHPRunner project

define('WP_USE_THEMES', false);

// modify path to Wordpress folder if required
require('../wordpress/wp-blog-header.php');
$user=wp_get_current_user();
$username = $user->user_login;
$displayname = $user->display_name;
$group = $user->allcaps["administrator"]==1 ? "administrator" : "";
if ($username!="")
{
$_SESSION["UserID"] = $username;
$_SESSION["GroupID"] = $group;
$_SESSION["UserName"] = $displayname;
if ($group=='administrator')
$_SESSION["AccessLevel"] = ACCESS_LEVEL_ADMIN;
else
$_SESSION["AccessLevel"] = ACCESS_LEVEL_USER;

}
else
{
$_SESSION["UserID"] = "";
$_SESSION["AccessLevel"] = "";
$_SESSION["GroupID"] = "";
$_SESSION["UserName"] = "";
}

4. In any post insert iframe code snippet pointing to one of PHPRunner pages:

[iframe http://localhost/phprunner/documents_list.php 650 400]

If you done everything right you are supposed to see something like this:

If something went wrong you will see PHPRunner's login page in iframe.

need2sleepDevClub member 6/13/2015

Thanks Serg!
You helped me find a solution to a scenario I was about to tackle.
Currently going to create a new project with an "ADD Page" which will connect to the main DB on another server from another project. This will help me a lot.
Much appreciated for this tutorial!

N
nrodrz 1/13/2016

Hi
Need to be that plugging? Show is not updated in the last couple of years..

A
alang 7/19/2020

Does this need to be updated to account for the Session Keys added in PHPR 10.3? I can see the correct data (according to group permissions) in the PHPR project but get "Your session has expired. Login to save data" error when trying to save any data.

A
alang 7/21/2020

I got around the problem by using Security class functions to do the login/logout. In step 3, instead of setting up the SESSION variables, just get the $username and call Security::login() - I found it best to test if the current user was different, then call Security::logout() before login.
BTW I recommend Advanced iFrame by Michael Dempfle - seems very capable with the free version and there is a Pro version for only $19.

fhumanes 7/22/2020

Hi
For inspiration, read this message.
https://asprunner.com/forums/topic/26898-integrate-phprunner-data-into-wordpress
Greetings,
Fernando

A
alang 9/3/2020

Update: For my WordPress environment, loading the wordpress file '../wordpress/wp-blog-header.php' caused MAJOR issues with the PHPRunner application:

  • Import did not work
  • Export did not work
  • Custom buttons did not work (at least the second and third stages)
  • Slashes got added to text fields in front of single and double quote marks



Resolved by creating an environment variable to hold WordPress user details and only including the file first time through with redirect to repeat after the first call.