Use of Action hook in wordpress to prepopulate form field - wordpress

I'm new to wordpress actions and i'm trying two things.
I'm tying to output the data based on a action hook.
The documentation of the plugin only says the following:
6. Action eideasy_user_identified. Runs immediately after user data has been received and includes array of data returned by eID Easy.
Does anybody has a tip on how to output this data?
And even better how to use the output from this data to prepopulate form fields from another wordpress plugin.
I realy hope someone can help me or give me a example to get started.
Thank you

The plugin in the picture is eID Easy
Here's how you can log the data in a file:
Step 1: Create a file called log.txt
Step 2: Create a file called eid-log.php
Put the below code in the eid-log.php file:
<?php
/**
* eID LOG
*
* #package eID LOG
* #author Vinay
* #license gplv2-or-later
* #version 1.0.0
*
* #wordpress-plugin
* Plugin Name: eID LOG
* Plugin URI: https://stackoverflow.com/questions/73491338/use-of-action-hook-in-wordpress-to-prepopulate-form-field
* Description: Log the eID data in a file
* Version: 1.0.0
* Author: Vinay Jain
* Author URI: https://stackoverflow.com/users/17995563/vinay-jain
* Text Domain: eid-log
* Domain Path: /languages
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*
* You should have received a copy of the GNU General Public License
* along with Hot Recipes. If not, see <https://www.gnu.org/licenses/gpl-2.0.html/>.
*/
add_action('eideasy_user_identified', 'eid_log_to_file', 10, 1);
function eid_log_to_file($result){
if (!is_null($result)) {
$myfile = fopen(plugin_dir_path( __FILE__ )."log.txt", "w");
fwrite($myfile, "==================================");
fwrite($myfile, print_r($result, true));
fclose($myfile);
}
}
Step 3: Zip both the files and name it eid-log.zip, then go to Wp-admin > Plugins > Add new > Upload
Step 4. Activate the plugin and then use your eID Easy plugin.
Step 5: Read the log.txt file for the data.
This will log each entry in the log.txt file. This should work, if not then let me know.

Related

Headless WordPress GraphQL endpoint results in 404 URL not found with XAMPP

I am trying to consume a GraphQL endpoint (autogenerated from a headless WordPress project) which is served over XAMPP Apache localhost server, but when I hit the endpoint with suggested from the GraphQL settings in WordPress (https://localhost/does-pizza/graphql) I get back a 404 URL not found.
Some details that could be useful to anybody trying to answer this question:
The project folder name is actually 'does-pizza', hence the autogenerated endpoint
The WordPress side of my project works just fine, in fact, I am able to send GraphQL queries through the provided Ide
The wp-config.php just in case you need it
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the installation.
* You don't have to use the web site, you can copy this file to "wp-config.php"
* and fill in the values.
*
* This file contains the following configurations:
*
* * Database settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* #link https://wordpress.org/support/article/editing-wp-config-php/
*
* #package WordPress
*/
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'does_pizza' );
/** Database username */
define( 'DB_USER', 'root' );
/** Database password */
define( 'DB_PASSWORD', '' );
/** Database hostname */
define( 'DB_HOST', 'localhost' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' );
/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
/**##+
* Authentication unique keys and salts.
*
* Change these to different unique phrases! You can generate these using
* the {#link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
*
* You can change these at any point in time to invalidate all existing cookies.
* This will force all users to have to log in again.
*
* #since 2.6.0
*/
define( 'AUTH_KEY', '/fOC;iXzZpRnq[-,Qks$w!.rdjZO?m^A1|lI:k,}i$*.YzsJzpd)Q&S4)O0JpU^P' );
define( 'SECURE_AUTH_KEY', '`0TnWd!<k+cCa9EIH7+P`g>BqZnyJ<NM8Z`;7u%sm%r4gQFS#%Qj53vi8n7P|):b' );
define( 'LOGGED_IN_KEY', '05Y6C;<O%V5Ng<gP%W]vTnO2X;qc%;ncm8#,,0#Q#,UlmDl!{&yPzMa-cdh<2>I$' );
define( 'NONCE_KEY', 'Lf_NZQ,~-EI]!4KU4c682fy0xovx]r&jXG70J^-tRms(NQ=,7,rZYW8siDyVd,({' );
define( 'AUTH_SALT', 'aw!Cmo?uv>l 0Ph#{;T[)G9,XdzT+M~unG!M6A1R)}Jbu3QUC}&+~/taon{~U{9}' );
define( 'SECURE_AUTH_SALT', ')]#jI2IJZySp)b<Io~!xwY%ADUmXbbl^AH#gty({Bhjl4XsjJPw+1[?r/](6^Q8}' );
define( 'LOGGED_IN_SALT', '}T:i=Y_9ET#(uWLLu$u?p1k{V1M7t$#0=XX}!>lIa>T.[E>$4$s6 EF#>F+L;O,S' );
define( 'NONCE_SALT', 'uf3S3C.]HaSPazeZgM^HNTLb<v63QFhT[t`W|`qZL$MdrY/$bOljiU^PaFb~=En:' );
/**##-*/
/**
* WordPress database table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the documentation.
*
* #link https://wordpress.org/support/article/debugging-in-wordpress/
*/
define( 'WP_DEBUG', false );
/* Add any custom values between this line and the "stop editing" line. */
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';
The same request in Postman
In Postman I am disabling the SLL certificate, just because I want to see the request succeed, but I'd of course rather use it
I have tried to call both localhost on port 443 and 80 but I get the same result
This is the first time I try to do something like this, so if you need any extra piece of information just let me know it.
Thanks in advance for any help :)
I have finally found the answer.
Based on the Permalink settings in WordPress, I had to change https://localhost/does-pizza/graphql to https://localhost/does-pizza/index.php?graphql

Wordpress activate_plugin() can run and return "The plugin does not have a valid header."

hello i tried to build plugin that can install and activate other plugins. the plugins is successfully extracted to "wp-content/plugins" folder but there error when activate_plugin() function running, it return "The plugin does not have a valid header.". Did i do it wrong?
this my plugin script:
<?php
define( 'WP_ADMIN', TRUE );
define( 'WP_NETWORK_ADMIN', TRUE );
define( 'WP_USER_ADMIN', TRUE );
require_once('../../../wp-load.php');
require_once(ABSPATH.'wp-admin/includes/admin.php');
require_once(ABSPATH.'wp-admin/includes/file.php');
require_once(ABSPATH.'wp-admin/includes/plugin.php');
try {
$post = $_POST;
// file_put_contents('logs.txt', json_encode($post));die;
foreach($post['plugins'] as $key => $value){
if($value['is_external_link'] == 0){
$file_url = $post['url_download']."/{$value['id']}";
}else{
$file_url = $value['external_link'];
}
$tmp_file = download_url($file_url);
copy($tmp_file, $value['file_name']);
unlink($tmpfile);
// extract plugin to plugins folder
$zip = new ZipArchive;
$zip->open($value['file_name']);
$zip->extractTo(ABSPATH.'wp-content/plugins/');
$zip->close();
// remove zip file
unlink($value['file_name']);
// activate plugin
$res = activate_plugin(ABSPATH.'wp-content/plugins/'.$value['folder_name']);
file_put_contents("logs$key.txt", $res->get_error_messages());
}
} catch (\Throwable $th) {
file_put_contents('log.txt', $th);
}
Oh the problem already clear, i just need to include the core file script, so instead of "wp-content/plugins/plugin-name/", change to "wp-content/plugins/plugin-name/plugin-name.php".
Oviously, your code missing plugin header right after the open <?php tag.
It's some thing like this:
/**
* Plugin Name: My Basics Plugin
* Plugin URI: https://example.com/plugins/the-basics/
* Description: Handle the basics with this plugin.
* Version: 1.10.3
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: John Smith
* Author URI: https://author.example.com/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: my-basics-plugin
* Domain Path: /languages
*/
Or atleat you need the Plugin Name to activate it!!

Changing The Site URL doesn't work Wordpress

I have a problem with Changing The Site URL in Wordpress. I don't know what I'm doing wrong.
I copy my website from fryzjer.make4u.pl.
I created subdomen demo1.make4u.pl and took out my files from fryzjer.make4u.pl.
When I enter to demo1.make4u.pl redirection me to fryzjer.make4u.pl.
I change code in file wp-config.php
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
* * MySQL settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* #link https://codex.wordpress.org/Editing_wp-config.php
*
* #package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
define('WP_HOME','http://demo1.make4u.pl');
define('WP_SITEURL','http://demo1.make4u.pl');
/** The name of the database for WordPress */
define('DB_NAME', 'pawwlak_demo1');
/** MySQL database username */
define('DB_USER', 'pawwlak_demo1');
/** MySQL database password */
define('DB_PASSWORD', '*******');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8mb4');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
/**##+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {#link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* #since 2.6.0
*/
define('AUTH_KEY', '2zYYuJ)vQk.)[u9YZN|?nH$%,upKR.|M9LU~Ia?U<xR%_Nkjm-Y(0qCc2+>s[4~f');
define('SECURE_AUTH_KEY', '*m0QP$nkR1p(DKM?mQvl5h`yI%8TcdNCE,S!Kdu9I6a~:&Wu/nXV?9pKW1n!&2xw');
define('LOGGED_IN_KEY', 'ekZe)AMW#r[rux$OB2WH<`B_l*+$[v8:^bNGqjps+kEF!|ENpm5gN<]8)p7cg7QE');
define('NONCE_KEY', 'dC1<i[BWhz*T#L(`8P`gz}J2/YA67?~Ps<0g G)#a1N_`Mx+nN^%MW4q)NU;.5/%');
define('AUTH_SALT', 'x.zML}$pIbtCGp-/A44kFZB[uLY~;0R9#I0]W~lc9DyLlKU`]HeUSk)$6/(75T}v');
define('SECURE_AUTH_SALT', 'dT`KJVh6|xjevK/3:#t3C?IcE0>q%} tFWkT-}I*H60wA|lf);Z1m9bV]G;*qwc/');
define('LOGGED_IN_SALT', 'GeDCcC$uR^6e(4(TjF94N$Yh<QIpt_?^q.Ixy{LBW=eez&Ql_7/CqS1r+R;uP+31');
define('NONCE_SALT', 'DO.kU/6]s<k<+kfbE`EWf$:f>5G%Q9WPGjE?^0AS3,&OcLfGnY6pgd.orwdq`~C(');
/**##-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the Codex.
*
* #link https://codex.wordpress.org/Debugging_in_WordPress
*/
define('WP_DEBUG', false);
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
Do you know why it dosen't work?
You defined the wrong constants. The top of your wp-config.php file should be:
define('HOME','http://demo1.make4u.pl');
define('SITEURL','http://demo1.make4u.pl');
Note that WP_HOME became HOME and WP_SITEURL became SITEURL.
Alternatively, if this does not work for you, try connecting to the database, navigate to the wp_options table, and adjust the entries for home and siteurl to your new URL's.
If you are confident in using SQL queries on your database, you can make use if yuyokk's code as a SQL Query which will do a comprehensive find/replace in your database:
REMEMBER: Backup your database before attempting any SQL Queries!
UPDATE wp_options
SET option_value = 'http://demo1.make4u.pl'
WHERE option_name = 'home';
UPDATE wp_options
SET option_value = 'http://demo1.make4u.pl'
WHERE option_name = 'siteurl';
UPDATE wp_posts
SET post_content = REPLACE(post_content,'http://fryzjer.make4u.pl','http://demo1.make4u.pl');
UPDATE wp_posts
SET guid = REPLACE(guid,'http://fryzjer.make4u.pl','http://demo1.make4u.pl');

Wordpress PHP - Parse Error

I'm having trouble logging onto the Admin page of my website www.millcroftrealestate.com
It says "Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in /home/sting692/public_html/millcroftrealestate.com/wp-config.php on line 90"
Here's the PHP code:
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {#link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
* installation. You don't have to use the web site, you can just copy this file
* to "wp-config.php" and fill in the values.
*
* #package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'sting692_wrdp11');
/** MySQL database username */
define('DB_USER', 'sting692_wrdp11');
/** MySQL database password */
define('DB_PASSWORD', 'wxbnCVNnz5d9');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
/**##+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {#link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* #since 2.6.0
*/
define('AUTH_KEY', '#j?ipQ1nR,yuuCW#Umillcroftrealestate.comAS-{%gQEpSr_+<dyb+>:Yd#nWbetyh~4rmMUap4Q6rZEcZy');
define('SECURE_AUTH_KEY', '+hOIBXnJ~C;ftmT([CA|]_wDSmillcroftrealestate.comG<K?#S8{H>//EaLy7]h:jhRfj.K=Usg#g&$9+ox');
define('LOGGED_IN_KEY', 'c8K?-u_wU{BZ2yHK_sbOo1#?!millcroftrealestate.com}H<`PM%7^l6VJTY,~DSOJ,zCtVI#Ym$WZi1#5x5');
define('NONCE_KEY', 's5,9YV+%:+HFX#l~ %RE`AZ/pmillcroftrealestate.comUzn<&<R%71t-|[H-L+}AtN9/thH&dMcVM8WN|Q}');
define('AUTH_SALT', 'KUEIq#~d.Tk+~t>1:HS9$8G_*millcroftrealestate.comzG,jcuq2l=7l#KE[-1c)QW3a{LwGi-kwhRVP&]g');
define('SECURE_AUTH_SALT', ';0GoKVCGWIZh:YOa*h[]-T&Dimillcroftrealestate.comnp=:iQ;z$>OkEYNi2#Y`|5-c|n:Jb #}97E?LX7');
define('LOGGED_IN_SALT', 'we3RP{hVolwbVh-((L%LEcHKlmillcroftrealestate.com[IaA9<bDvi`h/M:3U7xK8S]A|.Q,2$|*jcOqWNB');
define('NONCE_SALT', '~<MckLITBiGaIV)497^JDbe-)millcroftrealestate.comG:*}/Prup?HeQMLNLz2kG~d/306X7Noin#gGh7+');
/**##-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each a unique
* prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* WordPress Localized Language, defaults to English.
*
* Change this to localize WordPress. A corresponding MO file for the chosen
* language must be installed to wp-content/languages. For example, install
* de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
* language support.
*/
define('WPLANG', '');
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
define('WP_DEBUG', false);
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php’);
?>
The line with a parse error according to Komodo is the second last one "require_once(ABSPATH . 'wp-settings.php’);"
I'm not at all familiar with PHP and thought someone with experience might be able to fix it easily. Any help would be much appreciated. Thanks!
Change this ’ with singlequote '
require_once(ABSPATH . 'wp-settings.php');

Wordpress Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in /home/chilinbk/public_html/kunde/tkh/wp-config.php on line 100
Line 100 is the last one. But I cant figure it out!
Hope someone can help me.
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {#link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
* installation. You don't have to use the web site, you can just copy this file
* to "wp-config.php" and fill in the values.
*
* #package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', '');
/** MySQL database username */
define('DB_USER', '');
/** MySQL database password */
define('DB_PASSWORD', '');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
/**##+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {#link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* #since 2.6.0
*/
define('AUTH_KEY', 'if4tkr3z8umc1m9k94gja2agq8tyuc5adboxyccimlswfocnozsiekmpso2udgin');
define('SECURE_AUTH_KEY', 'l5pf9yf02yqfztyxfwz8ustkskcu3h1fuozohxnibjhwdpchqa9x43gx7nrsvirn');
define('LOGGED_IN_KEY', 'sv1pejwz3p9uujbpojwukoceleeagrrrwxqgnwuv3aahricp8eelrxme3yicdafa');
define('NONCE_KEY', 'sxizz7mc0kmafx0plgqmyub5jetjqtsudnwxlegcxtza3nc3xv0nqo4aqap8imzl');
define('AUTH_SALT', 'z674t27gm67tvjtq1achhdwxz2rmnrs7dht3a8vsanxwt9wsviab4ku7jeadhnxw');
define('SECURE_AUTH_SALT', 'pjob5np9us1ob4e3oqkmyevc82n6vhagpoz4e4ezrwc8as0osejirfkomkgbtjuf');
define('LOGGED_IN_SALT', 'c4h8ag0aalctr7rxhj15iqqknpwv7wivqdqmnybowwbylwynlf7bk6vmcjfmyt5n');
define('NONCE_SALT', 'jtid8ydl4wq6wxgnxlfgsm7icpghitdkrgtkp7dix7oicyfrkgvp9m0kwtloupmi');
/**##-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each a unique
* prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* WordPress Localized Language, defaults to English.
*
* Change this to localize WordPress. A corresponding MO file for the chosen
* language must be installed to wp-content/languages. For example, install
* de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
* language support.
*/
define ('WPLANG', '');
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
define('WP_DEBUG', false);
define('WP_ALLOW_MULTISITE', true);
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
$base = '/tkh/';
define( 'DOMAIN_CURRENT_SITE', 'kunde.chiliweb.no' );
define( 'PATH_CURRENT_SITE', '/tkh/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
p');
The last row ( p'); ) looks like a fragment from a line present there before. Just delete the remainders or restore to a previous version and you are fine.

Resources