WordPress Plugin Activation triggers a Fatal Error












0















I know there are many questions like this but I couldn't find any that pinged on the specifics relevant to my case. Either that or they went unanswered.



I've written a pretty simple PHP script and uploaded to a wordPress site in a zip folder and when I try to activate the plugin, WordPress gives me a message reading: "Plugin could not be activated because it triggered a fatal error." It does not actually give me any error message. I have WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY all set to true, but none of these are updated upon the supposed error. It seems I have no way of finding out what exactly the fatal error is.



I'm kind've at a loss as to how to proceed with this problem. Any help would be useful.



<?php

/*
Plugin Name: Denrile's Plogger
Plugin URI: http://my-awesomeness-emporium.com
description: >- a plugin to that takes the user to the Pruvan website,
after using CURL to log them in so that the redirect doesn't hit a user authentication wall.
Version: 1.0
Author: John Mauran
Author URI: http://github.com/jmauran91
License: GPL2
*/

$j_username = "Denrile";
$j_password = "*************";
$login_url ="https://titlereporter.direct.pruvan.com/v2/login";
$last_url = "https://titlereporter.direct.pruvan.com/v2/pmgr";


function loginToJulian($url, $username, $password){
$curl = curl_init();
$header[0]= "Accept: application/json, text/javascript, */*; q=0.01";
$header = "Cache-Control: max-age=0";
$header = "Connection: keep-alive";
$header = "Content-Type: application/x-www-form-urlencoded";
$header = "Keep-Alive: 300";
$header = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header = "Accept-Language: en-us,en;q=0.5";
$verbose = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_STDERR, $verbose);
// Make the errors visible in a new file

$payload_username = '"'.$username.'"';
$payload_password = '"'.$password.'"';
$payloadtext=urlencode('{"username":'.$payload_username.',"password":'.$payload_password.'}');
$payload = "payload=".$payloadtext;
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$store = curl_exec($curl);
curl_close($store);
}

if(isset($_GET['prvn_login'])){
loginToJulian($login_url, $j_username, $j_password);
header("Location: https://titlereporter.direct.pruvan.com/v2/pmgr");
exit();
}
else{

exit();
}

?>


The general idea of this plugin is that it will hook into a javascript-generated A-tag on the wordPress site, CURL Post to another site to login, and then re-direct to that site, hopefully bypassing the user authentication since the user will already be logged in thanks to the CURL.










share|improve this question























  • Is your wp-content folder writable? If so, you should have a debug.log file in there. Did you check it already?

    – cabrerahector
    Nov 26 '18 at 2:35
















0















I know there are many questions like this but I couldn't find any that pinged on the specifics relevant to my case. Either that or they went unanswered.



I've written a pretty simple PHP script and uploaded to a wordPress site in a zip folder and when I try to activate the plugin, WordPress gives me a message reading: "Plugin could not be activated because it triggered a fatal error." It does not actually give me any error message. I have WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY all set to true, but none of these are updated upon the supposed error. It seems I have no way of finding out what exactly the fatal error is.



I'm kind've at a loss as to how to proceed with this problem. Any help would be useful.



<?php

/*
Plugin Name: Denrile's Plogger
Plugin URI: http://my-awesomeness-emporium.com
description: >- a plugin to that takes the user to the Pruvan website,
after using CURL to log them in so that the redirect doesn't hit a user authentication wall.
Version: 1.0
Author: John Mauran
Author URI: http://github.com/jmauran91
License: GPL2
*/

$j_username = "Denrile";
$j_password = "*************";
$login_url ="https://titlereporter.direct.pruvan.com/v2/login";
$last_url = "https://titlereporter.direct.pruvan.com/v2/pmgr";


function loginToJulian($url, $username, $password){
$curl = curl_init();
$header[0]= "Accept: application/json, text/javascript, */*; q=0.01";
$header = "Cache-Control: max-age=0";
$header = "Connection: keep-alive";
$header = "Content-Type: application/x-www-form-urlencoded";
$header = "Keep-Alive: 300";
$header = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header = "Accept-Language: en-us,en;q=0.5";
$verbose = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_STDERR, $verbose);
// Make the errors visible in a new file

$payload_username = '"'.$username.'"';
$payload_password = '"'.$password.'"';
$payloadtext=urlencode('{"username":'.$payload_username.',"password":'.$payload_password.'}');
$payload = "payload=".$payloadtext;
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$store = curl_exec($curl);
curl_close($store);
}

if(isset($_GET['prvn_login'])){
loginToJulian($login_url, $j_username, $j_password);
header("Location: https://titlereporter.direct.pruvan.com/v2/pmgr");
exit();
}
else{

exit();
}

?>


The general idea of this plugin is that it will hook into a javascript-generated A-tag on the wordPress site, CURL Post to another site to login, and then re-direct to that site, hopefully bypassing the user authentication since the user will already be logged in thanks to the CURL.










share|improve this question























  • Is your wp-content folder writable? If so, you should have a debug.log file in there. Did you check it already?

    – cabrerahector
    Nov 26 '18 at 2:35














0












0








0








I know there are many questions like this but I couldn't find any that pinged on the specifics relevant to my case. Either that or they went unanswered.



I've written a pretty simple PHP script and uploaded to a wordPress site in a zip folder and when I try to activate the plugin, WordPress gives me a message reading: "Plugin could not be activated because it triggered a fatal error." It does not actually give me any error message. I have WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY all set to true, but none of these are updated upon the supposed error. It seems I have no way of finding out what exactly the fatal error is.



I'm kind've at a loss as to how to proceed with this problem. Any help would be useful.



<?php

/*
Plugin Name: Denrile's Plogger
Plugin URI: http://my-awesomeness-emporium.com
description: >- a plugin to that takes the user to the Pruvan website,
after using CURL to log them in so that the redirect doesn't hit a user authentication wall.
Version: 1.0
Author: John Mauran
Author URI: http://github.com/jmauran91
License: GPL2
*/

$j_username = "Denrile";
$j_password = "*************";
$login_url ="https://titlereporter.direct.pruvan.com/v2/login";
$last_url = "https://titlereporter.direct.pruvan.com/v2/pmgr";


function loginToJulian($url, $username, $password){
$curl = curl_init();
$header[0]= "Accept: application/json, text/javascript, */*; q=0.01";
$header = "Cache-Control: max-age=0";
$header = "Connection: keep-alive";
$header = "Content-Type: application/x-www-form-urlencoded";
$header = "Keep-Alive: 300";
$header = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header = "Accept-Language: en-us,en;q=0.5";
$verbose = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_STDERR, $verbose);
// Make the errors visible in a new file

$payload_username = '"'.$username.'"';
$payload_password = '"'.$password.'"';
$payloadtext=urlencode('{"username":'.$payload_username.',"password":'.$payload_password.'}');
$payload = "payload=".$payloadtext;
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$store = curl_exec($curl);
curl_close($store);
}

if(isset($_GET['prvn_login'])){
loginToJulian($login_url, $j_username, $j_password);
header("Location: https://titlereporter.direct.pruvan.com/v2/pmgr");
exit();
}
else{

exit();
}

?>


The general idea of this plugin is that it will hook into a javascript-generated A-tag on the wordPress site, CURL Post to another site to login, and then re-direct to that site, hopefully bypassing the user authentication since the user will already be logged in thanks to the CURL.










share|improve this question














I know there are many questions like this but I couldn't find any that pinged on the specifics relevant to my case. Either that or they went unanswered.



I've written a pretty simple PHP script and uploaded to a wordPress site in a zip folder and when I try to activate the plugin, WordPress gives me a message reading: "Plugin could not be activated because it triggered a fatal error." It does not actually give me any error message. I have WP_DEBUG, WP_DEBUG_LOG, and WP_DEBUG_DISPLAY all set to true, but none of these are updated upon the supposed error. It seems I have no way of finding out what exactly the fatal error is.



I'm kind've at a loss as to how to proceed with this problem. Any help would be useful.



<?php

/*
Plugin Name: Denrile's Plogger
Plugin URI: http://my-awesomeness-emporium.com
description: >- a plugin to that takes the user to the Pruvan website,
after using CURL to log them in so that the redirect doesn't hit a user authentication wall.
Version: 1.0
Author: John Mauran
Author URI: http://github.com/jmauran91
License: GPL2
*/

$j_username = "Denrile";
$j_password = "*************";
$login_url ="https://titlereporter.direct.pruvan.com/v2/login";
$last_url = "https://titlereporter.direct.pruvan.com/v2/pmgr";


function loginToJulian($url, $username, $password){
$curl = curl_init();
$header[0]= "Accept: application/json, text/javascript, */*; q=0.01";
$header = "Cache-Control: max-age=0";
$header = "Connection: keep-alive";
$header = "Content-Type: application/x-www-form-urlencoded";
$header = "Keep-Alive: 300";
$header = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header = "Accept-Language: en-us,en;q=0.5";
$verbose = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_STDERR, $verbose);
// Make the errors visible in a new file

$payload_username = '"'.$username.'"';
$payload_password = '"'.$password.'"';
$payloadtext=urlencode('{"username":'.$payload_username.',"password":'.$payload_password.'}');
$payload = "payload=".$payloadtext;
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$store = curl_exec($curl);
curl_close($store);
}

if(isset($_GET['prvn_login'])){
loginToJulian($login_url, $j_username, $j_password);
header("Location: https://titlereporter.direct.pruvan.com/v2/pmgr");
exit();
}
else{

exit();
}

?>


The general idea of this plugin is that it will hook into a javascript-generated A-tag on the wordPress site, CURL Post to another site to login, and then re-direct to that site, hopefully bypassing the user authentication since the user will already be logged in thanks to the CURL.







php wordpress






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 26 '18 at 1:51









JohnJohn

557




557













  • Is your wp-content folder writable? If so, you should have a debug.log file in there. Did you check it already?

    – cabrerahector
    Nov 26 '18 at 2:35



















  • Is your wp-content folder writable? If so, you should have a debug.log file in there. Did you check it already?

    – cabrerahector
    Nov 26 '18 at 2:35

















Is your wp-content folder writable? If so, you should have a debug.log file in there. Did you check it already?

– cabrerahector
Nov 26 '18 at 2:35





Is your wp-content folder writable? If so, you should have a debug.log file in there. Did you check it already?

– cabrerahector
Nov 26 '18 at 2:35












1 Answer
1






active

oldest

votes


















1














This code works for me.
But one question, Why you added exit(); inside the else condition, It is breaking the plugin activation process.



Please check and let me know.



<?php

/*
Plugin Name: Denrile's Plogger
Plugin URI: http://my-awesomeness-emporium.com
description: >- a plugin to that takes the user to the Pruvan website,
after using CURL to log them in so that the redirect doesn't hit a user authentication wall.
Version: 1.0
Author: John Mauran
Author URI: http://github.com/jmauran91
License: GPL2
*/

$j_username = "Denrile";
$j_password = "*************";
$login_url ="https://titlereporter.direct.pruvan.com/v2/login";
$last_url = "https://titlereporter.direct.pruvan.com/v2/pmgr";


function loginToJulian($url, $username, $password){
$curl = curl_init();
$header[0]= "Accept: application/json, text/javascript, */*; q=0.01";
$header = "Cache-Control: max-age=0";
$header = "Connection: keep-alive";
$header = "Content-Type: application/x-www-form-urlencoded";
$header = "Keep-Alive: 300";
$header = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header = "Accept-Language: en-us,en;q=0.5";
$verbose = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_STDERR, $verbose);
// Make the errors visible in a new file

$payload_username = '"'.$username.'"';
$payload_password = '"'.$password.'"';
$payloadtext=urlencode('{"username":'.$payload_username.',"password":'.$payload_password.'}');
$payload = "payload=".$payloadtext;
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$store = curl_exec($curl);
curl_close($store);
}


function default_wordpress_hook(){
if(isset($_GET['prvn_login'])){
loginToJulian($login_url, $j_username, $j_password);
header("Location: https://titlereporter.direct.pruvan.com/v2/pmgr");
exit();
} else {

}
}
add_action("init","default_wordpress_hook");

?>





share|improve this answer
























  • thank you, that worked, although I don't understand why / why mine didn't work?

    – John
    Nov 26 '18 at 17:11











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53473828%2fwordpress-plugin-activation-triggers-a-fatal-error%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














This code works for me.
But one question, Why you added exit(); inside the else condition, It is breaking the plugin activation process.



Please check and let me know.



<?php

/*
Plugin Name: Denrile's Plogger
Plugin URI: http://my-awesomeness-emporium.com
description: >- a plugin to that takes the user to the Pruvan website,
after using CURL to log them in so that the redirect doesn't hit a user authentication wall.
Version: 1.0
Author: John Mauran
Author URI: http://github.com/jmauran91
License: GPL2
*/

$j_username = "Denrile";
$j_password = "*************";
$login_url ="https://titlereporter.direct.pruvan.com/v2/login";
$last_url = "https://titlereporter.direct.pruvan.com/v2/pmgr";


function loginToJulian($url, $username, $password){
$curl = curl_init();
$header[0]= "Accept: application/json, text/javascript, */*; q=0.01";
$header = "Cache-Control: max-age=0";
$header = "Connection: keep-alive";
$header = "Content-Type: application/x-www-form-urlencoded";
$header = "Keep-Alive: 300";
$header = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header = "Accept-Language: en-us,en;q=0.5";
$verbose = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_STDERR, $verbose);
// Make the errors visible in a new file

$payload_username = '"'.$username.'"';
$payload_password = '"'.$password.'"';
$payloadtext=urlencode('{"username":'.$payload_username.',"password":'.$payload_password.'}');
$payload = "payload=".$payloadtext;
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$store = curl_exec($curl);
curl_close($store);
}


function default_wordpress_hook(){
if(isset($_GET['prvn_login'])){
loginToJulian($login_url, $j_username, $j_password);
header("Location: https://titlereporter.direct.pruvan.com/v2/pmgr");
exit();
} else {

}
}
add_action("init","default_wordpress_hook");

?>





share|improve this answer
























  • thank you, that worked, although I don't understand why / why mine didn't work?

    – John
    Nov 26 '18 at 17:11
















1














This code works for me.
But one question, Why you added exit(); inside the else condition, It is breaking the plugin activation process.



Please check and let me know.



<?php

/*
Plugin Name: Denrile's Plogger
Plugin URI: http://my-awesomeness-emporium.com
description: >- a plugin to that takes the user to the Pruvan website,
after using CURL to log them in so that the redirect doesn't hit a user authentication wall.
Version: 1.0
Author: John Mauran
Author URI: http://github.com/jmauran91
License: GPL2
*/

$j_username = "Denrile";
$j_password = "*************";
$login_url ="https://titlereporter.direct.pruvan.com/v2/login";
$last_url = "https://titlereporter.direct.pruvan.com/v2/pmgr";


function loginToJulian($url, $username, $password){
$curl = curl_init();
$header[0]= "Accept: application/json, text/javascript, */*; q=0.01";
$header = "Cache-Control: max-age=0";
$header = "Connection: keep-alive";
$header = "Content-Type: application/x-www-form-urlencoded";
$header = "Keep-Alive: 300";
$header = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header = "Accept-Language: en-us,en;q=0.5";
$verbose = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_STDERR, $verbose);
// Make the errors visible in a new file

$payload_username = '"'.$username.'"';
$payload_password = '"'.$password.'"';
$payloadtext=urlencode('{"username":'.$payload_username.',"password":'.$payload_password.'}');
$payload = "payload=".$payloadtext;
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$store = curl_exec($curl);
curl_close($store);
}


function default_wordpress_hook(){
if(isset($_GET['prvn_login'])){
loginToJulian($login_url, $j_username, $j_password);
header("Location: https://titlereporter.direct.pruvan.com/v2/pmgr");
exit();
} else {

}
}
add_action("init","default_wordpress_hook");

?>





share|improve this answer
























  • thank you, that worked, although I don't understand why / why mine didn't work?

    – John
    Nov 26 '18 at 17:11














1












1








1







This code works for me.
But one question, Why you added exit(); inside the else condition, It is breaking the plugin activation process.



Please check and let me know.



<?php

/*
Plugin Name: Denrile's Plogger
Plugin URI: http://my-awesomeness-emporium.com
description: >- a plugin to that takes the user to the Pruvan website,
after using CURL to log them in so that the redirect doesn't hit a user authentication wall.
Version: 1.0
Author: John Mauran
Author URI: http://github.com/jmauran91
License: GPL2
*/

$j_username = "Denrile";
$j_password = "*************";
$login_url ="https://titlereporter.direct.pruvan.com/v2/login";
$last_url = "https://titlereporter.direct.pruvan.com/v2/pmgr";


function loginToJulian($url, $username, $password){
$curl = curl_init();
$header[0]= "Accept: application/json, text/javascript, */*; q=0.01";
$header = "Cache-Control: max-age=0";
$header = "Connection: keep-alive";
$header = "Content-Type: application/x-www-form-urlencoded";
$header = "Keep-Alive: 300";
$header = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header = "Accept-Language: en-us,en;q=0.5";
$verbose = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_STDERR, $verbose);
// Make the errors visible in a new file

$payload_username = '"'.$username.'"';
$payload_password = '"'.$password.'"';
$payloadtext=urlencode('{"username":'.$payload_username.',"password":'.$payload_password.'}');
$payload = "payload=".$payloadtext;
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$store = curl_exec($curl);
curl_close($store);
}


function default_wordpress_hook(){
if(isset($_GET['prvn_login'])){
loginToJulian($login_url, $j_username, $j_password);
header("Location: https://titlereporter.direct.pruvan.com/v2/pmgr");
exit();
} else {

}
}
add_action("init","default_wordpress_hook");

?>





share|improve this answer













This code works for me.
But one question, Why you added exit(); inside the else condition, It is breaking the plugin activation process.



Please check and let me know.



<?php

/*
Plugin Name: Denrile's Plogger
Plugin URI: http://my-awesomeness-emporium.com
description: >- a plugin to that takes the user to the Pruvan website,
after using CURL to log them in so that the redirect doesn't hit a user authentication wall.
Version: 1.0
Author: John Mauran
Author URI: http://github.com/jmauran91
License: GPL2
*/

$j_username = "Denrile";
$j_password = "*************";
$login_url ="https://titlereporter.direct.pruvan.com/v2/login";
$last_url = "https://titlereporter.direct.pruvan.com/v2/pmgr";


function loginToJulian($url, $username, $password){
$curl = curl_init();
$header[0]= "Accept: application/json, text/javascript, */*; q=0.01";
$header = "Cache-Control: max-age=0";
$header = "Connection: keep-alive";
$header = "Content-Type: application/x-www-form-urlencoded";
$header = "Keep-Alive: 300";
$header = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header = "Accept-Language: en-us,en;q=0.5";
$verbose = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_STDERR, $verbose);
// Make the errors visible in a new file

$payload_username = '"'.$username.'"';
$payload_password = '"'.$password.'"';
$payloadtext=urlencode('{"username":'.$payload_username.',"password":'.$payload_password.'}');
$payload = "payload=".$payloadtext;
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$store = curl_exec($curl);
curl_close($store);
}


function default_wordpress_hook(){
if(isset($_GET['prvn_login'])){
loginToJulian($login_url, $j_username, $j_password);
header("Location: https://titlereporter.direct.pruvan.com/v2/pmgr");
exit();
} else {

}
}
add_action("init","default_wordpress_hook");

?>






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 26 '18 at 7:45









Ankit PanchalAnkit Panchal

1064




1064













  • thank you, that worked, although I don't understand why / why mine didn't work?

    – John
    Nov 26 '18 at 17:11



















  • thank you, that worked, although I don't understand why / why mine didn't work?

    – John
    Nov 26 '18 at 17:11

















thank you, that worked, although I don't understand why / why mine didn't work?

– John
Nov 26 '18 at 17:11





thank you, that worked, although I don't understand why / why mine didn't work?

– John
Nov 26 '18 at 17:11




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53473828%2fwordpress-plugin-activation-triggers-a-fatal-error%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin