stanleyboise
Forum Replies Created
-
Forum: Plugins
In reply to: [Favorites] PHP Warnings fills my error.log fileI am not a coder. Altough, I asked IA a few questions with hope to find a fix to this issue:
Question 01:
Can you check if this code is ok:
public function startSession()
{
if ( $this->settings_repo->saveType() !== ‘session’ ) return;
if ( !session_id() ) session_start();
}IA Answer 01:
The code you provided is fine, but it’s not complete. It’s a method inside a class that checks whether the saveType of settings_repo is ‘session’ and if the session is not started already, it starts a session.I created a class named ‘MyClass’ with your ‘startSession’ method. I’ve added a constructor method to the class to initialize ‘settings_repo’. This class needs to be instantiated with an object that has a ‘saveType’ method returning a string.
Remember, using session_start() without proper handling can cause issues such as headers already sent warning. Also, using sessions can have implications on where your application can be deployed as not all server configurations will handle session data the same way.
IA Suggested code output:class MyClass { protected $settings_repo; public function __construct($settings_repo){ $this->settings_repo = $settings_repo; } public function startSession() { if ($this->settings_repo->saveType() !== 'session') { return; } if (!session_id()) { session_start(); } } }
Question 02:
“How to solve:
PHP Warning: session_start(): Session cannot be started after headers have already been sent in”IA Answer 02:
The PHP warning “session_start(): Session cannot be started after headers have already been sent” occurs when there is output sent to the browser before the session_start() function is called. This warning typically occurs when there is whitespace or any other content (such as HTML tags or echo/print statements) sent to the browser before starting a session.To solve this issue, you can follow these steps:
- Make sure to call the session_start() function before any output is sent to the browser. Ideally, the session_start() function should be called at the very beginning of your PHP code, before any HTML or whitespace.
- Check for any whitespace or output before the session_start() function. Make sure there are no spaces, new lines, or any other characters before the opening
<?php
tag. - If you have any include or require statements before the session_start() function, ensure that none of those files have any output or whitespace before the session_start() call.
Hope there is an easy fix to this.
Kind Regards,Forum: Plugins
In reply to: [Classic Editor] Compatible with WP 5.9.3?It still work with WP6
Thanks for your screenshots and help.
Although, I still can’t edit:
Cette page est restreinte. Veuillez Connexion pour afficher cette page.It sounds as if this string has a problem in the code.
This is related to the page where I have [wpuf_account] shortcode.
Someone who is not logged in, will see this message. But… I need to edit it to improve the syntax so it makes sense.The part which I need to change is: Connexion
I want to message to show as:
Cette page est restreinte. Veuillez vous connecter pour afficher cette page.Kind Regards,
Forum: Plugins
In reply to: [Loops & Logic] Need validation. Please@tangibleinc Sorry. Found it here:
https://discourse.tangible.one/t/define-format-for-publish-date/471Forum: Plugins
In reply to: [Loops & Logic] Need validation. Please@tangibleinc Oh! How would you specify a special format to <Field publish_date />? I don’t clearly understand. I wish to have the publish date to show without the time. Like: <Date format=”Y-m-d” />
Forum: Plugins
In reply to: [Loops & Logic] Need validation. Please@tangibleinc
Big thanks for your precisions on this.
Much appreciated.