WordPress Plugin Activation triggers a Fatal Error
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
add a comment |
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
Is yourwp-content
folder writable? If so, you should have adebug.log
file in there. Did you check it already?
– cabrerahector
Nov 26 '18 at 2:35
add a comment |
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
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
php wordpress
asked Nov 26 '18 at 1:51
JohnJohn
557
557
Is yourwp-content
folder writable? If so, you should have adebug.log
file in there. Did you check it already?
– cabrerahector
Nov 26 '18 at 2:35
add a comment |
Is yourwp-content
folder writable? If so, you should have adebug.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
add a comment |
1 Answer
1
active
oldest
votes
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");
?>
thank you, that worked, although I don't understand why / why mine didn't work?
– John
Nov 26 '18 at 17:11
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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");
?>
thank you, that worked, although I don't understand why / why mine didn't work?
– John
Nov 26 '18 at 17:11
add a comment |
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");
?>
thank you, that worked, although I don't understand why / why mine didn't work?
– John
Nov 26 '18 at 17:11
add a comment |
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");
?>
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");
?>
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Is your
wp-content
folder writable? If so, you should have adebug.log
file in there. Did you check it already?– cabrerahector
Nov 26 '18 at 2:35