Cant receive email about restoring password in WordPress [closed]

i have registration form

and also form for restoring password

i was need to change template of letter for mail

because i wanna put some information like this ( =>

<p>Если у вас возникли трудности или ошибки – оставьте тикет в службу поддержки.</p>
                <p><strong><a href="%s">Служба технической поддержки</a></strong></p>

) in mail letter

i made this code for solving my task(code include in the down)

<?php
function custom_new_user_notification_email($wp_new_user_notification_email, $user, $blogname) {
    // Проверяем, что это именно письмо о регистрации нового пользователя
    if (isset($_POST['reg_password'])) {
        $support_link = 'some link';
        $login_link = 'some link';

        // Получаем пароль пользователя из поля формы
        $user_pass = isset($_POST['reg_password']) ? $_POST['reg_password'] : 'Пароль не найден';

        $wp_new_user_notification_email['subject'] = 'Добро пожаловать на ' . $blogname;

        $wp_new_user_notification_email['headers'] = array('Content-Type: text/html; charset=UTF-8');

        $wp_new_user_notification_email['message'] = sprintf(
            '<html>
            <head>
                <style>
                    body { font-family: Arial, sans-serif; font-size: 14px; color: #333; }
                    a { color: #0073aa; text-decoration: none; }
                </style>
            </head>
            <body>
                <p>Привет, %s!</p>
                <p>Спасибо за регистрацию на сайте <strong><a href="some link">golitsina.com</a></strong>.</p>
                <p>Ваш логин: <strong>%s</strong></p>
                <p>Ваш пароль: <strong>%s</strong></p>
                <p>Чтобы войти, используйте ссылку: <a href="%s">Войти</a></p>
                <p>Если у вас возникли трудности или ошибки – оставьте тикет в службу поддержки.</p>
                <p><strong><a href="%s">Служба технической поддержки</a></strong></p>
            </body>
            </html>',
            $user->display_name,
            $user->user_login,
            $user_pass,
            $login_link,
            $support_link
        );
    }

    return $wp_new_user_notification_email;
}

add_filter('wp_new_user_notification_email', 'custom_new_user_notification_email', 10, 3);

and registation form was works as i wanna

but after i noticed that when i make reset of password – mail did’t come in my email, but registration form works as before

if i will delete my new code – everything works and i will receive mail if i will restore password

i was read in some place that this

wp_new_user_notification_email

have some connection with template of restoring password

i checked folder Spam

i tried make checking by this because after making reset my url will have url like this – ?reset-link-sent=true

if ( isset( $_GET['reset-link-sent'] ) && $_GET['reset-link-sent'] === 'true' ) {
        return $wp_new_user_notification_email; 
    }

but didnt help

i havent access to activate debugging, only wordpress – therefore i dont see mistakes

its mean problem now that i cant make restoring of password – because i will not receive mail

PHP Datatable rowspan and colspan [closed]

I need help to create colspan in datatables. Because HTML’s rowspan and colspan attribute are not working in datatables. In below code as you can see else part is creating a single column. and It’s creating issue as there is originally two columns. I want to merge 2 columns and display no records found message so the datable’s error message pop up can be remove.

<?php if(!empty($break_arr)) { 
    $breaks         = unserialize($break_arr);

    foreach ($breaks as $break) { ?>
        <td>
            <p><?php echo date("h:i:s A", $break['start']); ?> to <?php echo date("h:i:s A", $break['end']); ?></p>
        </td>
    <?php }
} else { ?>
    <td>
        <p><?php _e('No Break Record found.', 'wphrm'); ?></p>
    </td>    
<?php }

I have tried colspan from html but it’s not working. Does anyone have any idea about it?

Requesting a route of a non-existent class

I’m Trying to send request to a route that gives me Target Class [AuthController] does not exist.

So, I’m trying to access a route defined in api.php file.

This is my api.php file.

<?php

use IlluminateHttpRequest;
use IlluminateSupportFacadesRoute;
use AppHttpControllersAuthController;

Route::get("/welcome",[AuthController::class, "helloWorld"]);

This is my AuthController.php file

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppModelsUser;
use IlluminateSupportFacadesHash;
use IlluminateSupportFacadesValidator;
use Throwable;

class AuthController extends Controller
{
    public function helloWorld(Request $request)
    {
        return response()->json([
            "message" => "Hello World",
        ]);
    }
}

However, trying to access the route gives error Target Class [AuthController] does not exist.

I’m pretty sure that i’ve set up the controller properly. I’m using laravel version 11.31.

I’ve tried the same thing in two different projects but the error is still persists. I’m new to Laravel and don’t know how to fix it. Any help would be appreciated.

Laravel Nginx Docker Always return 404 [closed]

So, I’m trying to run a Laravel App inside a Docker Container, so I managed to successfuly build and run the container, but whenever I access it from a web browser it always return 404 Not Found from Nginx.

404 Not Found from Nginx.

So, this is my Dockerfile :

FROM php:8.0-fpm-alpine AS build

RUN apk --no-cache add bash libpng-dev libjpeg-turbo-dev freetype-dev zip git nginx && 
    docker-php-ext-configure gd --with-freetype --with-jpeg && 
    docker-php-ext-install gd pdo pdo_mysql

RUN curl -sS https://getcomposer.org/installer | php && 
    mv composer.phar /usr/local/bin/composer

WORKDIR /var/www

COPY . .

RUN composer install --no-dev --optimize-autoloader

FROM php:8.0-fpm-alpine

RUN apk --no-cache add bash libpng-dev libjpeg-turbo-dev freetype-dev zip git nginx && 
    docker-php-ext-configure gd --with-freetype --with-jpeg && 
    docker-php-ext-install gd pdo pdo_mysql

WORKDIR /var/www

COPY --from=build /var/www /var/www

COPY nginx/default.conf /etc/nginx/conf.d/default.conf

RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache

EXPOSE 80 9000

CMD ["sh", "-c", "php-fpm & nginx -g 'daemon off;'"]

And this is my default.conf for Nginx :

server {
    listen 80;
    server_name localhost;

    root /var/www/public;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ .php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /.ht {
        deny all;
    }

    error_log /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
}

I’ve been trying over and over to build and rebuild the container, but still I get the 404 result from Nginx, I really appreciate if there’s any solution available that I can try, Iv’ve been googling and using ChatGPT for days, but still no result, thank you.

I’ve been trying to get rid of Nginx and simply run the Laravel App on port 9000 directly, but I get connection timeout instead.

FROM php:8.0-fpm-alpine AS build

WORKDIR /var/www

RUN apk --no-cache add bash libpng-dev libjpeg-dev libfreetype6-dev zip git && 
    docker-php-ext-configure gd --with-freetype --with-jpeg && 
    docker-php-ext-install gd pdo pdo_mysql

RUN curl -sS https://getcomposer.org/installer | php && 
    mv composer.phar /usr/local/bin/composer

COPY . .

RUN composer install --no-dev --optimize-autoloader

FROM php:8.0-fpm-alpine

WORKDIR /var/www

RUN apk --no-cache add bash libpng-dev libjpeg-dev libfreetype6-dev zip git && 
    docker-php-ext-configure gd --with-freetype --with-jpeg && 
    docker-php-ext-install gd pdo pdo_mysql

COPY --from=build /var/www /var/www

EXPOSE 9000

CMD ["php-fpm"]

PHP Error Array to string conversion -> Implode array to string

I would like to get the infos from a post_meta in wordpress, I receive datas from a form most of the fields are good execpt the array one which it gives me this error :

Warning: Array to string conversion line 140

the line :

$value = get_post_meta($postid, "nature_handicap", true)

what i’ve tried :

Nature du handicap * : <br><br>
';
$value = get_post_meta($postid, "nature_handicap", true);
if (is_array($value)) {
    $value = implode(",", $value);
}

 '
<br><br>

I ve tried to implode the array to a string, I was expectiong to receive my array as a string split with some comas

How to debug filter in WooCommerce Product Sync with Xdebug?

I am using the WooCommerce Product Sync plugin, and I am working with the following two filters to modify product data during synchronization:

  1. wps_product_fields – This filter is triggered on the “parent” site when a product is updated. It builds an array of WooCommerce product data, and I am adding extra fields to this array for use on the receiving site.

  2. woocommerce_rest_pre_insert_product_object – This filter is triggered on the receiving site when it receives product data.

I am using Xdebug for debugging, and breakpoints work fine when I trigger the wps_product_fields filter on the parent site. However, when I set breakpoints inside the woocommerce_rest_pre_insert_product_object filter on the receiving site, Xdebug does not seem to detect anything running.

I suspect this is happening because the WooCommerce Product Sync plugin processes data in the background. It’s switching to the receiving site, picking up the incoming data and processing, but XDEBUG can’t seem to see that.

What I’ve Tried:

  • Ensuring Xdebug is properly configured and breakpoints are working in other parts of the code.

  • Attempting to manually log data to confirm the hook is running. On run, I have it updating my product title just as a means to keep checking if it changes or not.

Question:

How can I get Xdebug breakpoints to trigger when the woocommerce_rest_pre_insert_product_object filter runs, given that the plugin works in the background? (I think).

Any insights on debugging background processes in WooCommerce with Xdebug would be appreciated.

Session keeps renewing when checking the status

In my laravel/inertia/vue application I’d like to check if the session is expired or not. If the session has expired, a popup should be displayed. The check is done by making a call to the backend. I’m using the session database driver.

In the backend – as a matter of fact, it will be moved to a controller if working accordingly:

Route::get('/session-status', function (IlluminateHttpRequest $request) {
    $sessionId = cookie(config('session.cookie'));

    if (!IlluminateSupportFacadesAuth::check()) {
        return response()->json(['session_expired' => true], 401);
    }

    // Fetch session directly from the database (without updating last_activity)
    $sessionId = $request->session()->getId();
    $session = IlluminateSupportFacadesDB::table('sessions')
        ->select('last_activity')
        ->where('id', $sessionId)
        ->first();

    if ($session) {
        $sessionLifetime = config('session.lifetime') * 60;
        $sessionAge = now()->timestamp - $session->last_activity;

        if ($sessionAge > $sessionLifetime) {
            return response()->json(['session_expired' => true], 401);
        }
    }

    return response()->json(['session_expired' => false]);
})->name('session.status');

In the frontend a simple axios call is made:

const showPopup = ref(false);

const checkSession = async () => {
    try {
        await axios.get('/api/session-status');
    } catch (error) {
        if (error.response && error.response.status === 401) {
            showPopup.value = true;
        }
    }
};

// Run session check every 1 minute
onMounted(() => {
    setInterval(checkSession, 6000);
});

I’ve tried many many options, but laravel keeps on renewing the session if the session is still active. This is nice behaviour when working in the application, but undesired for just checking the session status, as it creates a “drip” keeping the session alive forever.

Anybody a solution?

Symfony 7.2 Use behind reverseproxy with custom location [closed]

I want to publish my symfony 7.2 webapp. I dont use a custom subdomain or domain. I want to use an path domain.com/webapp. Unfortunately I cant configure that proxy. The main page is also loading but all the assets are getting loaded from domain.com/css/… not domain.com/webapp/css/… How can I deal with that?

The assets are not the only problem. I just want a simple solution where I set the basepath at one point.

Thank you!

How to select the column in my database using my own API? [closed]

So I am trying to create an API for my personal project to fetch data. And it is working pretty nicely until I have to select a single column.

Here in this code I am trying to add the column parameter and then take data. I am using postman to check the API and when I send request, I get the complete table no matter what.

This is my index.php file.

<?php
include 'C:xampphtdocsphpAPIsincludeFilesdatabase.php';
include 'C:xampphtdocsphpAPIsincludeFilesredirectRequest.php';
include 'C:xampphtdocsphpAPIsincludeFilesprocessRequest.php';

$method = $_SERVER["REQUEST_METHOD"];
$url = trim($_SERVER["REQUEST_URI"], "/");
$urlParts = explode("/", $url);
var_dump($urlParts);
parse_str($_SERVER['QUERY_STRING'], result: $params);

header('Content-Type: application/json');

$database = $urlParts[2]; // Default database
$table = $urlParts[3]; // Table name
$column=$urlParts[4];


$pdo = new Database("localhost", "root", "", $database);
$redirect = new RedirectRequest($pdo);
$process = new ProcessRequest($redirect);

$process->handleRequest($method, $table, $column, $params);

?>

This is the handleGet method where I am passing the parameters to select the data from database.

    private function handleGet($table,$column, $params)
    {
        $limit = trim($params['limit'], '"') ?? 20;
        $orderBy = trim($params['orderBy'], '"') ?? null;
        $order = trim($params['order'], '"') ?? "ASC";
        
        $records = $this->redirectRequest->getAll($table, $column, $limit, $orderBy, $order);
        echo json_encode($records);
    }

And this is the redirectRequest.php where the SQL execution takes place:

    public function getAll($table, $column, $limit = 20, $orderBy = null, $order = "ASC")
    {
        $pdo = $this->database->getPDO();

        // Prevent SQL Injection in ORDER BY
        $order = strtoupper($order) === "DESC" ? "DESC" : "ASC";
        $orderByClause = $orderBy ? "ORDER BY `$orderBy` $order" : "";
        if($column==="all")
        {
            $column="*";
        }
        $query = "SELECT". $column ."FROM `$table` $orderByClause LIMIT :limit";
        $stmt = $pdo->prepare($query);
        $stmt->bindValue(":limit", (int) $limit, PDO::PARAM_INT);
        $stmt->execute();
        return $stmt->fetchAll();
    }

  

This is how I passed the request in the Postman:
https://localhost/testapi-v2-test/index.php/userlist/listall/animeid
and I get data from whole table.

Here ‘userlist’ is the database ‘listall’ is the table and ‘animeid’ is the column in the table. But even if I am passing this I get complete table returned to me. And if I pass this:

https://localhost/testapi-v2-test/index.php/userlist/listall/, I do get the error for the missing parameter as this:
<br /> <b>Warning</b>: Undefined array key 4 in <b>C:xampphtdocstestAPI-V2-testindex.php</b> on line <b>16</b><br /> and then the whole table is shown too

Stripe Express Checkout not accepting Gpay or Apple Pay. But works in elements

We have a payment flow whereby a payment intent is created with the following options

$options = [
            'customer'                  => $stripeCustomerId,
            'amount'                    => $amount,
            'currency'                  => 'gbp',
            'automatic_payment_methods' => [
                'enabled' => 'true',
            ],
        ];

We then present our customers with a payment form which utilises both Stripe Elements (for card payments) And Express Checkout (For GPay/Apple Pay).

Stripe elements works fine, and is fully functional. However, when adding in express checkout, and trying the payment flow, the following error is returned from Stripe:
You cannot confirm this PaymentIntent because it's missing a payment method. To confirm the PaymentIntent with CUSTOMER_ID, specify a payment method attached to this customer along with the customer ID.

We instantiate express checkout as follows:

const expressCheckoutOptions = {
            buttonType: {
                applePay: 'order',
                googlePay: 'order',
            },
            layout: {
                maxColumns: 1,
            }
        }

        expressElements = stripe.elements({
            mode: 'payment',
            amount: Number(window.payment.payment_amount),
            currency:'gbp',
        });

        const expressCheckoutElement = expressElements.create('expressCheckout', expressCheckoutOptions)
        expressCheckoutElement.mount('#express-checkout');

And then we confirm the payment like so:

expressCheckoutElement.on('confirm', async (event) => {
            const {error: submitError} = await expressElements.submit();
            if (submitError) {
                showMessage(submitError.message);
                return;
            }

            let clientSecret = 'Our Client Secret'
            const {error} = await stripe.confirmPayment({
                expressElements,
                clientSecret,
                confirmParams: {
                    return_url: window.location.href,
                },
                redirect: 'if_required',
            });

            if (error) {
                showMessage(error.message);
            } else {
                console.log('Payment confirmation successful!');
            }
        });
    }

This integration is taken moreorless verbatim from the Stripe docs, however, the error mentioned above is thrown. Any help is greatly appreciated!

Code has been snippeted for privacy

How to check server connectivity without using the ping command and implement it with AJAX in Laravel?

I want to check the connectivity of remote servers without using the ping command in Laravel. The reason for avoiding ping is the potential security risks, such as command injection vulnerabilities when using exec().

Additionally, I want to implement this connectivity check asynchronously using AJAX so that the status updates periodically on the frontend without reloading the page.

I initially used

exec("ping -c 2 " . escapeshellarg($ip)) 

in PHP, but I realized it could pose a security risk.

I also considered using fsockopen(), but I am unsure if it is the best solution.

My goal is to find a safe and reliable way to check server availability and update the status dynamically via AJAX requests in Laravel.

During inheritance of ArrayAccess: Uncaught ErrorException: Return type of IlluminateSupportCollection::offsetExists($key) should either be

I have an old laravel app (v6) that is still running on PHP 7.4

Laravel and PHP versions both out of support, I know! That upgrade is a task for another day.

But strange error started when running composer update.

/usr/bin/php7.2 /usr/bin/composer upgrade


During inheritance of ArrayAccess: Uncaught ErrorException: Return type of IlluminateSupportCollection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool,   
  or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/core/vendor/laravel/framework/src/Illuminate/Support/Collection.php:1277            
  Stack trace:                                                                                                                                                                                                    
  #0 /var/www/html/core/vendor/laravel/framework/src/Illuminate/Support/Collection.php(11): IlluminateFoundationBootstrapHandleExceptions->handleError()                                        
  #1 /var/www/html/core/vendor/composer/ClassLoader.php(576): include('...')                                                                                                                       
  #2 /var/www/html/core/vendor/composer/ClassLoader.php(427): ComposerAutoload{closure}()                                                                                                        
  #3 /var/www/html/core/vendor/laravel/framework/src/Illuminate/Support/helpers.php(109): ComposerAutoloadClassLoader->loadClass()                                                               
  #4 /var/www/html/core/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(89): collect()                                                                                      
  #5 /var/www/html/core/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(78): IlluminateFoundationPackageManifest->config()                                                
  #6 /var/www/html/core/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterFacades.php(26): IlluminateFoundationPackageManifest->aliases()                                     
  #7 /var/www/html/core/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(219): IlluminateFoundationBootstrapRegisterFacades->bootstrap()                                      
  #8 /var/www/html/core/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(320): IlluminateFoundationApplication->bootstrapWith()                                             
  #9 /var/www/html/core/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): IlluminateFoundationConsoleKernel->bootstrap()                                              
  #10 /var/www/html/core/artisan(34): IlluminateFoundationConsoleKernel->handle()                                                                                                               
  #11 {main}      

This error seems to be a mismatch between php version and code format, however the error doesn’t make sense.

https://www.php.net/manual/en/class.returntypewillchange.php The
ReturnTypeWillChange attribute (PHP 8 >= 8.1.0)

This attribute suggested in the error message didn’t even exist until php8.1 yet I and specifying php7.4

So logically, the php version I am doesn’t even know this attribute so could not suggest this solution in the error message.

/usr/bin/php7.4 -v
PHP 7.4.33 (cli) (built: Dec 24 2024 07:11:50) ( NTS )

Also odd is that running Artisan command things work fine on 7.4 and error on 8.1

/usr/bin/php7.4 artisan --version
Laravel Framework 6.20.45

/usr/bin/php8.1 artisan --version
PHP Fatal error:  During inheritance of ArrayAccess: Uncaught ErrorException: Return type of IlluminateSupportCollection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $of

This confirms that the error is running php7.4 compatible version of IlluminateSupportCollection on php8.1

But I am running the command in php7.4, so this shouldn’t happen!

Have regularly run composer by passing it to a specific php version which always works great, but something seems to be switching php version randomly mid process.

Have tried downgrade to composer2.2 but still same error.

How do I change encoding in PHPRunner?

I have the following problem. I created a database view with PHPRunner. I host the project with Xampp and it works fine. Until I want to open a table where one of the table fields has a äöü in it or even if it has a foreign key from a table where one of the fields has one of these special charakters. I have checked in PHPRunner, every table view is generated in UTF-8 so it should display the tables. I am truly at a loss. When I view it with localhost I can open the site without a problem.

Some time ago I wanted to program something in PHP but I couldn’t get it to work so I bought PHPRunner. Did I maybe mess up something there? I’ve deleted and reinstalled Xampp multiple times.

Thank You!

The occuring Error

The Error description says "invalid column "Veröffentlicht""

Reinstalling Xampp
Changing everything to UTF-8

Old prestashop site broke with error “The CSRF token is invalid.”

I help maintain an old PrestaShop site, but a few days ago, it suddenly broke for no apparent reason. To my knowledge, no changes were made to the server or the site. Interestingly, there are two sites running on the same server instance, and both are experiencing the same issue.

When attempting to update a product description, I encounter the following error:

The CSRF token is invalid. Please try to resubmit the form.

Additionally, the description form itself appears to be broken:
Have no idea where this "of 80000 characters allowed" is coming from.
enter image description here

How do I change or overwrite the content of html in a function?

I need to change the input field step from step=”0.01″ to step=”100″ in functions.php of a child theme so that parent theme stays untouched.

Here is the code I am trying to change from my child theme functions.php

<?php
    class WPTRequestsNewFieldsContent {
        public function budget_to( $placeholder = '' ) {

            if ( wpt_get_option( 'wptheme_request_budget' ) == "yes" ) {
                $post_value = WPT_Form::post( 'request_budget_to', get_post_meta( $this->pid, 'request_budget_to', true ) ); ?>


                <div class="ui basic">
                <input
                    type="number"
                    min="0"
                    step="0.01"
                    placeholder="<?php echo $placeholder ? $placeholder : _x( 'The price at which your request ends', 'Post new request', 'wptheme' ); ?>"
                    id="request_budget_to"
                    value="<?php echo $post_value; ?>"
                    name="request_budget_to"
                />
                </div>

            <?php } else { ?>

                <div class="disabled-field"></div>

            <?php }

        }
    }
?>