<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wordpress Archives - CNERIS</title>
	<atom:link href="https://cneris.com/en/category/wordpress-en/feed/" rel="self" type="application/rss+xml" />
	<link>https://cneris.com/en/category/wordpress-en/</link>
	<description></description>
	<lastBuildDate>Sun, 18 May 2025 16:34:28 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
	<item>
		<title>How can we protect wp-login without any plugins?</title>
		<link>https://cneris.com/en/how-can-we-protect-wp-login-without-any-plugins/</link>
					<comments>https://cneris.com/en/how-can-we-protect-wp-login-without-any-plugins/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sun, 18 May 2025 16:34:28 +0000</pubDate>
				<category><![CDATA[Computer Security]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[protect your wordpress]]></category>
		<category><![CDATA[wp-login]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2750</guid>

					<description><![CDATA[<p>Protect with .htaccess and .htpasswd: Create a .htpasswd file:Use an online htpasswd generator to create a user and encrypted password.Save it outside the public directory (e.g., /home/username/.htpasswd). Edit your .htaccess file:Open the .htaccess file in the root of your WordPress site, or create one in the same directory as wp-login.php: &lt;Files wp-login.php&gt; AuthType Basic AuthName [...]</p>
<p>The post <a href="https://cneris.com/en/how-can-we-protect-wp-login-without-any-plugins/">How can we protect wp-login without any plugins?</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p class="" data-start="1172" data-end="1213"><strong data-start="1172" data-end="1213">Protect with .htaccess and .htpasswd:</strong></p>
<ol data-start="1215" data-end="2026">
<li class="" data-start="1215" data-end="1458">
<p class="" data-start="1218" data-end="1458"><strong data-start="1218" data-end="1248">Create a <code data-start="1229" data-end="1240">.htpasswd</code> file:</strong><br data-start="1248" data-end="1251" />Use an <a class="cursor-pointer" target="_new" rel="noopener" data-start="1261" data-end="1339">online htpasswd generator</a> to create a user and encrypted password.<br data-start="1380" data-end="1383" />Save it outside the public directory (e.g., <code data-start="1430" data-end="1456">/home/username/.htpasswd</code>).</p>
</li>
<li class="" data-start="1460" data-end="1889">
<p class="" data-start="1463" data-end="1616"><strong data-start="1463" data-end="1494">Edit your <code data-start="1475" data-end="1486">.htaccess</code> file:</strong><br data-start="1494" data-end="1497" />Open the <code data-start="1509" data-end="1520">.htaccess</code> file in the root of your WordPress site, or create one in the same directory as <code data-start="1601" data-end="1615">wp-login.php</code>:</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary">
<div class="overflow-y-auto p-4" dir="ltr"><code class="whitespace-pre! language-apache">&lt;Files wp-login.php&gt;<br />
AuthType Basic<br />
AuthName "Restricted Access"<br />
AuthUserFile /full/path/to/.htpasswd<br />
Require valid-user<br />
&lt;/Files&gt;<br />
</code></div>
</div>
<p class="" data-start="1806" data-end="1889">&#x26a0;&#xfe0f; Replace <code data-start="1817" data-end="1842">/full/path/to/.htpasswd</code> with the actual path to your <code data-start="1872" data-end="1883">.htpasswd</code> file.</p>
</li>
<li class="" data-start="1891" data-end="2026">
<p class="" data-start="1894" data-end="2026"><strong data-start="1894" data-end="1912">Save and test:</strong><br data-start="1912" data-end="1915" />When you visit <code data-start="1933" data-end="1947">wp-login.php</code>, it will now prompt for a username and password before showing the login page.</p>
</li>
</ol>
<p>The post <a href="https://cneris.com/en/how-can-we-protect-wp-login-without-any-plugins/">How can we protect wp-login without any plugins?</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/en/how-can-we-protect-wp-login-without-any-plugins/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to disable REST API access for unauthenticated users?</title>
		<link>https://cneris.com/en/how-to-disable-rest-api-access-for-unauthenticated-users/</link>
					<comments>https://cneris.com/en/how-to-disable-rest-api-access-for-unauthenticated-users/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 03 Dec 2024 20:52:48 +0000</pubDate>
				<category><![CDATA[Computer Security]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[disable rest api]]></category>
		<category><![CDATA[rest api]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2728</guid>

					<description><![CDATA[<p>The WordPress REST API is a powerful tool that allows interaction with your site through HTTP requests. However, there may be instances where you want to restrict API access, especially for unauthenticated users, for security or privacy reasons. How to disable REST API access for unauthenticated users? By default, WordPress allows certain REST API endpoints [...]</p>
<p>The post <a href="https://cneris.com/en/how-to-disable-rest-api-access-for-unauthenticated-users/">How to disable REST API access for unauthenticated users?</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The WordPress REST API is a powerful tool that allows interaction with your site through HTTP requests. However, there may be instances where you want to restrict API access, especially for unauthenticated users, for security or privacy reasons.</p>
<h4>How to disable REST API access for unauthenticated users?</h4>
<p>By default, WordPress allows certain REST API endpoints to be publicly accessible. To restrict this access, you can use the <code>rest_authentication_errors</code> filter. The following code blocks REST API requests for any unauthenticated user and returns a custom error message.</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<blockquote>
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none">add_filter(&#8216;rest_authentication_errors&#8217;, function($result) {<br />
if (!empty($result)) {<br />
return $result;<br />
}<br />
if (!is_user_logged_in()) {<br />
return new WP_Error(&#8216;rest_not_logged_in&#8217;, &#8216;You must log in to access the REST API.&#8217;, array(&#8216;status&#8217; =&gt; 401));<br />
}<br />
return $result;<br />
});</div>
</blockquote>
</div>
<h4>What does this code do?</h4>
<ol>
<li><strong>Filter <code>rest_authentication_errors</code></strong>: This filter is used to handle authentication errors in the REST API.</li>
<li><strong>Check for pre-existing errors</strong>: If <code>$result</code> already contains an error, it returns it as is.</li>
<li><strong>User session verification</strong>: If the user is not logged in (<code>!is_user_logged_in()</code>), it returns a <code>WP_Error</code> with a custom message and an HTTP 401 (Unauthorized) status code.</li>
<li><strong>Return results</strong>: If none of the above conditions are met, it proceeds with normal request handling.</li>
</ol>
<h4>Result</h4>
<p>With this code in place, any unauthenticated user will receive an error message stating they must log in to access the REST API. This effectively secures your REST API from unauthorized access.</p>
<p>The post <a href="https://cneris.com/en/how-to-disable-rest-api-access-for-unauthenticated-users/">How to disable REST API access for unauthenticated users?</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/en/how-to-disable-rest-api-access-for-unauthenticated-users/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to disable the REST API in WordPress using PHP code</title>
		<link>https://cneris.com/en/how-to-disable-the-rest-api-in-wordpress-using-php-code/</link>
					<comments>https://cneris.com/en/how-to-disable-the-rest-api-in-wordpress-using-php-code/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 03 Dec 2024 20:42:59 +0000</pubDate>
				<category><![CDATA[Computer Security]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[disable rest api]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2721</guid>

					<description><![CDATA[<p>The WordPress REST API allows applications to interact with your site remotely. However, in certain cases, you might want to disable it to enhance security or limit data access. Here’s how to disable the REST API in WordPress using PHP code: Steps: Open the functions.php file of your active theme or create a custom plugin [...]</p>
<p>The post <a href="https://cneris.com/en/how-to-disable-the-rest-api-in-wordpress-using-php-code/">How to disable the REST API in WordPress using PHP code</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The WordPress REST API allows applications to interact with your site remotely. However, in certain cases, you might want to disable it to enhance security or limit data access. Here’s how to disable the REST API in WordPress using PHP code:</p>
<p><strong>Steps:</strong></p>
<ol>
<li>Open the <code>functions.php</code> file of your active theme or create a custom plugin for this adjustment.</li>
<li>Add the following PHP code to disable the REST API for unauthenticated users:</li>
</ol>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php">function disable_rest_api( $access ) {<br />
if ( ! is_user_logged_in() ) {<br />
return new WP_Error( 'rest_cannot_access', __( 'REST API has been disabled for unauthenticated users.', 'your-text-domain' ), array( 'status' =&gt; 401 ) );<br />
}<br />
return $access;<br />
}<br />
add_filter( 'rest_authentication_errors', 'disable_rest_api' );<br />
</code></div>
</div>
<ol start="3">
<li>Save the changes and verify that unauthenticated users can no longer access the REST API.</li>
</ol>
<p>The post <a href="https://cneris.com/en/how-to-disable-the-rest-api-in-wordpress-using-php-code/">How to disable the REST API in WordPress using PHP code</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/en/how-to-disable-the-rest-api-in-wordpress-using-php-code/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Protect WordPress from User Enumeration</title>
		<link>https://cneris.com/en/how-to-protect-wordpress-from-user-enumeration/</link>
					<comments>https://cneris.com/en/how-to-protect-wordpress-from-user-enumeration/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 03 Dec 2024 20:28:13 +0000</pubDate>
				<category><![CDATA[Computer Security]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[user enumetarion]]></category>
		<category><![CDATA[wordpress security]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2714</guid>

					<description><![CDATA[<p>User enumeration is a common technique used by attackers to identify usernames on WordPress sites. Once usernames are discovered, attackers can use brute-force or other hacking techniques to compromise accounts. Here's how to secure your WordPress site against this vulnerability. 1. Limit Access to Sensitive Information Disable the ability to view user details via URLs [...]</p>
<p>The post <a href="https://cneris.com/en/how-to-protect-wordpress-from-user-enumeration/">How to Protect WordPress from User Enumeration</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>User enumeration is a common technique used by attackers to identify usernames on WordPress sites. Once usernames are discovered, attackers can use brute-force or other hacking techniques to compromise accounts. Here&#8217;s how to secure your WordPress site against this vulnerability.</p>
<h4><strong>1. Limit Access to Sensitive Information</strong></h4>
<ul>
<li>Disable the ability to view user details via URLs like <code>?author=1</code>.<br />
Add the following code to your <strong>functions.php</strong> file:</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none">php</div>
<div class="sticky top-9 md:top-[5.75rem]">
<div class="absolute bottom-0 right-2 flex h-9 items-center">
<div class="flex items-center rounded bg-token-sidebar-surface-primary px-2 font-sans text-xs text-token-text-secondary dark:bg-token-main-surface-secondary"><span class="" data-state="closed"><button class="flex gap-1 items-center select-none py-1">Copiar código</button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><span class="hljs-title function_ invoke__">add_action</span>(<span class="hljs-string">'template_redirect'</span>, function() {<br />
    <span class="hljs-keyword">if</span> (<span class="hljs-title function_ invoke__">is_author</span>()) {<br />
        <span class="hljs-title function_ invoke__">wp_redirect</span>(<span class="hljs-title function_ invoke__">home_url</span>());<br />
        <span class="hljs-keyword">exit</span>;<br />
    }<br />
});<br />
</code></div>
</div>
</li>
</ul>
<h4><strong>2. Use Security Plugins</strong></h4>
<p>Install plugins like <strong>Wordfence</strong> or <strong>All In One WP Security</strong> to monitor and block suspicious activities. These plugins can detect and prevent user enumeration attempts.</p>
<h4><strong>3. Block User Enumeration via .htaccess</strong></h4>
<p>For Apache servers, use the following code in the <code>.htaccess</code> file to block requests targeting usernames:</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none">apache</div>
<div class="sticky top-9 md:top-[5.75rem]">
<div class="absolute bottom-0 right-2 flex h-9 items-center">
<div class="flex items-center rounded bg-token-sidebar-surface-primary px-2 font-sans text-xs text-token-text-secondary dark:bg-token-main-surface-secondary"><span class="" data-state="closed"><button class="flex gap-1 items-center select-none py-1">Copiar código</button></span></div>
</div>
</div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-apache">RewriteCond %{QUERY_STRING} ^.*(author=\d+).*$<br />
RewriteRule ^(.*)$ /? [L,R=301]<br />
</code></div>
</div>
<h4><strong>4. Implement Strong Password Policies</strong></h4>
<p>Encourage all users to use strong passwords and enable two-factor authentication (2FA) to add an extra layer of security.</p>
<h4><strong>5. Monitor Logs for Suspicious Activity</strong></h4>
<p>Regularly review your website logs for unusual activity or repeated attempts to access user information.</p>
<h4><strong>6. Keep WordPress Updated</strong></h4>
<p>Always use the latest version of WordPress, plugins, and themes to ensure known vulnerabilities are patched.</p>
<p>By following these steps, you can significantly reduce the risk of user enumeration and keep your WordPress site secure.</p>
<p>The post <a href="https://cneris.com/en/how-to-protect-wordpress-from-user-enumeration/">How to Protect WordPress from User Enumeration</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/en/how-to-protect-wordpress-from-user-enumeration/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>The option &#8220;Hide other shipping methods when free shipping is available&#8221; is not displayed</title>
		<link>https://cneris.com/en/the-option-hide-other-shipping-methods-when-free-shipping-is-available-is-not-displayed/</link>
					<comments>https://cneris.com/en/the-option-hide-other-shipping-methods-when-free-shipping-is-available-is-not-displayed/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sun, 17 Nov 2024 22:22:01 +0000</pubDate>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[free shipping]]></category>
		<category><![CDATA[shipping methods]]></category>
		<category><![CDATA[woocommerce]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2706</guid>

					<description><![CDATA[<p>If the option "Hide other shipping methods when free shipping is available" is not displayed, you can achieve this behavior manually or by adding custom code. Option 1: Use predefined rules Go to WooCommerce &gt; Settings &gt; Shipping and select your shipping zone. Configure: A Free Shipping method with a minimum order of 60 euros. [...]</p>
<p>The post <a href="https://cneris.com/en/the-option-hide-other-shipping-methods-when-free-shipping-is-available-is-not-displayed/">The option &#8220;Hide other shipping methods when free shipping is available&#8221; is not displayed</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If the option <strong>&#8220;Hide other shipping methods when free shipping is available&#8221;</strong> is not displayed, you can achieve this behavior manually or by adding custom code.</p>
<h4>Option 1: Use predefined rules</h4>
<ol>
<li>Go to <strong>WooCommerce &gt; Settings &gt; Shipping</strong> and select your shipping zone.</li>
<li>Configure:
<ul>
<li>A <strong>Free Shipping</strong> method with a minimum order of 60 euros.</li>
<li>A <strong>Flat Rate Shipping</strong> method with a base cost of 5 euros.</li>
</ul>
</li>
<li>While WooCommerce may not automatically hide the flat rate, customers will be able to choose free shipping when eligible.</li>
</ol>
<h4>Option 2: Use custom code</h4>
<p>Add this code to your <code>functions.php</code> file to automatically hide other shipping methods when free shipping is available:</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php">add_filter( 'woocommerce_package_rates', 'hide_shipping_methods_when_free_is_available', 100 );<br />
function hide_shipping_methods_when_free_is_available( $rates ) {<br />
$free = array();<br />
foreach ( $rates as $rate_id =&gt; $rate ) {<br />
if ( 'free_shipping' === $rate-&gt;method_id ) {<br />
$free[ $rate_id ] = $rate;<br />
break;<br />
}<br />
}<br />
return ! empty( $free ) ? $free : $rates;<br />
}<br />
</code></div>
</div>
<h4>Final Step</h4>
<ul>
<li>Save your changes and refresh the checkout page to test</li>
</ul>
<p>The post <a href="https://cneris.com/en/the-option-hide-other-shipping-methods-when-free-shipping-is-available-is-not-displayed/">The option &#8220;Hide other shipping methods when free shipping is available&#8221; is not displayed</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/en/the-option-hide-other-shipping-methods-when-free-shipping-is-available-is-not-displayed/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>In the WordPress administration panel, how can I see the server&#8217;s performance?</title>
		<link>https://cneris.com/en/in-the-wordpress-administration-panel-how-can-i-see-the-servers-performance/</link>
					<comments>https://cneris.com/en/in-the-wordpress-administration-panel-how-can-i-see-the-servers-performance/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 29 Oct 2024 09:16:03 +0000</pubDate>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Query Monitor]]></category>
		<category><![CDATA[site health]]></category>
		<category><![CDATA[system information plugin]]></category>
		<category><![CDATA[WP-ServerInfo]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2687</guid>

					<description><![CDATA[<p>In the WordPress administration panel, how can I see the server's performance? Install a system information plugin Go to the WordPress admin panel, select Plugins &gt; Add New, and search for plugins like Site Health, WP-ServerInfo, or Query Monitor. Use "Site Health" WordPress includes a Site Health tool under Tools &gt; Site Health. Here, you [...]</p>
<p>The post <a href="https://cneris.com/en/in-the-wordpress-administration-panel-how-can-i-see-the-servers-performance/">In the WordPress administration panel, how can I see the server&#8217;s performance?</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In the WordPress administration panel, how can I see the server&#8217;s performance?</p>
<ul>
<li><strong>Install a system information plugin</strong><br />
Go to the WordPress admin panel, select <strong>Plugins &gt; Add New</strong>, and search for plugins like <strong>Site Health</strong>, <strong>WP-ServerInfo</strong>, or <strong>Query Monitor</strong>.</li>
<li><strong>Use &#8220;Site Health&#8221;</strong><br />
WordPress includes a <strong>Site Health</strong> tool under <strong>Tools &gt; Site Health</strong>. Here, you can view server environment details such as PHP version, memory limit, and maximum execution time.</li>
<li><strong>View additional details</strong><br />
For more specific information, you can install <strong>WP-ServerInfo</strong>. This plugin shows data about the server, such as MySQL version, CPU usage, RAM, and more.</li>
</ul>
<p>The post <a href="https://cneris.com/en/in-the-wordpress-administration-panel-how-can-i-see-the-servers-performance/">In the WordPress administration panel, how can I see the server&#8217;s performance?</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/en/in-the-wordpress-administration-panel-how-can-i-see-the-servers-performance/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>A PHP session was created by a session_start() function call. This interferes with REST API and loopback requests. The session should be closed by session_write_close() before making any HTTP requests.</title>
		<link>https://cneris.com/en/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-2/</link>
					<comments>https://cneris.com/en/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-2/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 29 Oct 2024 09:09:24 +0000</pubDate>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Dedicated servers]]></category>
		<category><![CDATA[Plesk]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[session_close]]></category>
		<category><![CDATA[session_start]]></category>
		<category><![CDATA[wordpress]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2680</guid>

					<description><![CDATA[<p>This error occurs because the session_start() function is creating a PHP session, which interferes with REST API and loopback requests in WordPress. To resolve this: Locate the session_start() code Search your theme or active plugins for the session_start() function. It may be in the theme’s functions.php file or in a custom plugin. Add session_write_close() after [...]</p>
<p>The post <a href="https://cneris.com/en/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-2/">A PHP session was created by a session_start() function call. This interferes with REST API and loopback requests. The session should be closed by session_write_close() before making any HTTP requests.</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This error occurs because the <code>session_start()</code> function is creating a PHP session, which interferes with REST API and loopback requests in WordPress. To resolve this:</p>
<ol>
<li><strong>Locate the <code>session_start()</code> code</strong><br />
Search your theme or active plugins for the <code>session_start()</code> function. It may be in the theme’s <code>functions.php</code> file or in a custom plugin.</li>
<li><strong>Add <code>session_write_close()</code> after <code>session_start()</code></strong><br />
Ensure <code>session_write_close()</code> is called after each <code>session_start()</code> call, before making any HTTP requests. This will close the session and allow the REST API to work correctly. For example:</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="sticky top-9 md:top-[5.75rem]"></div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><span class="hljs-title function_ invoke__">session_start</span>();<br />
<span class="hljs-comment">// Your code here</span><br />
<span class="hljs-title function_ invoke__">session_write_close</span>();<br />
</code></div>
</div>
</li>
<li><strong>Use the <code>init</code> hook in WordPress</strong><br />
If <code>session_start()</code> needs to be in <code>functions.php</code>, make sure to wrap it in the <code>init</code> hook and use <code>session_write_close()</code> like this:</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="sticky top-9 md:top-[5.75rem]"></div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><span class="hljs-title function_ invoke__">add_action</span>(<span class="hljs-string">'init'</span>, function() {<br />
    <span class="hljs-keyword">if</span> (!<span class="hljs-title function_ invoke__">session_id</span>()) {<br />
        <span class="hljs-title function_ invoke__">session_start</span>();<br />
        <span class="hljs-title function_ invoke__">session_write_close</span>();<br />
    }<br />
});</code></div>
</div>
</li>
</ol>
<p>The post <a href="https://cneris.com/en/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-2/">A PHP session was created by a session_start() function call. This interferes with REST API and loopback requests. The session should be closed by session_write_close() before making any HTTP requests.</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/en/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How you can set a default featured image for each post category</title>
		<link>https://cneris.com/en/how-you-can-set-a-default-featured-image-for-each-post-category/</link>
					<comments>https://cneris.com/en/how-you-can-set-a-default-featured-image-for-each-post-category/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 29 Oct 2024 08:59:48 +0000</pubDate>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Dedicated servers]]></category>
		<category><![CDATA[Plesk]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[featured image]]></category>
		<category><![CDATA[post category]]></category>
		<category><![CDATA[wordpress]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2671</guid>

					<description><![CDATA[<p>In WordPress, you can set a default featured image for each post category by using a snippet of code in your theme's functions.php file. This code checks if a post has a featured image assigned; if not, it sets a default image based on the post's category. Code to Assign Default Featured Image by Category [...]</p>
<p>The post <a href="https://cneris.com/en/how-you-can-set-a-default-featured-image-for-each-post-category/">How you can set a default featured image for each post category</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In WordPress, you can set a default featured image for each post category by using a snippet of code in your theme&#8217;s <code>functions.php</code> file. This code checks if a post has a featured image assigned; if not, it sets a default image based on the post&#8217;s category.</p>
<h4>Code to Assign Default Featured Image by Category</h4>
<ol>
<li>Open your theme&#8217;s <code>functions.php</code> file (preferably a child theme to avoid losing changes with updates).</li>
<li>Add the following code, replacing the URLs with your default images for each category:</li>
</ol>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><br />
</code></div>
</div>
<p>function set_default_thumbnail($post_id) {<br />
if (has_post_thumbnail($post_id)) {<br />
return;<br />
}</p>
<p>// Define default images for each category<br />
$default_images = [<br />
&#8216;category-1&#8217; =&gt; &#8216;https://your-site.com/wp-content/uploads/category-image1.jpg&#8217;,<br />
&#8216;category-2&#8217; =&gt; &#8216;https://your-site.com/wp-content/uploads/category-image2.jpg&#8217;,<br />
&#8216;category-3&#8217; =&gt; &#8216;https://your-site.com/wp-content/uploads/category-image3.jpg&#8217;,<br />
];</p>
<p>// Get post categories<br />
$categories = get_the_category($post_id);</p>
<p>// Check if categories are assigned and find a matching default image<br />
foreach ($categories as $category) {<br />
if (array_key_exists($category-&gt;slug, $default_images)) {<br />
$image_url = $default_images[$category-&gt;slug];</p>
<p>// Download image and set as featured image<br />
$image_id = attach_image_from_url($image_url, $post_id);<br />
if ($image_id) {<br />
set_post_thumbnail($post_id, $image_id);<br />
}<br />
break;<br />
}<br />
}<br />
}<br />
add_action(&#8216;save_post&#8217;, &#8216;set_default_thumbnail&#8217;);</p>
<p>// Function to download and attach the image to the post<br />
function attach_image_from_url($image_url, $post_id) {<br />
$upload_dir = wp_upload_dir();<br />
$image_data = file_get_contents($image_url);<br />
$filename = basename($image_url);</p>
<p>if (wp_mkdir_p($upload_dir[&#8216;path&#8217;])) {<br />
$file = $upload_dir[&#8216;path&#8217;] . &#8216;/&#8217; . $filename;<br />
} else {<br />
$file = $upload_dir[&#8216;basedir&#8217;] . &#8216;/&#8217; . $filename;<br />
}</p>
<p>file_put_contents($file, $image_data);</p>
<p>$wp_filetype = wp_check_filetype($filename, null);<br />
$attachment = [<br />
&#8216;post_mime_type&#8217; =&gt; $wp_filetype[&#8216;type&#8217;],<br />
&#8216;post_title&#8217; =&gt; sanitize_file_name($filename),<br />
&#8216;post_content&#8217; =&gt; &#8221;,<br />
&#8216;post_status&#8217; =&gt; &#8216;inherit&#8217;<br />
];</p>
<p>$attach_id = wp_insert_attachment($attachment, $file, $post_id);<br />
require_once(ABSPATH . &#8216;wp-admin/includes/image.php&#8217;);<br />
$attach_data = wp_generate_attachment_metadata($attach_id, $file);<br />
wp_update_attachment_metadata($attach_id, $attach_data);</p>
<p>return $attach_id;<br />
}</p>
<h4>Code Explanation</h4>
<ul>
<li><strong><code>$default_images</code></strong>: Defines default images for each category using the category slug as the key and the image URL as the value.</li>
<li><strong><code>set_default_thumbnail</code></strong>: This function runs when a post is saved. If the post has no featured image, it finds the first category with a default image in <code>$default_images</code> and sets it as the featured image.</li>
<li><strong><code>attach_image_from_url</code></strong>: This function downloads the image from the URL and attaches it to the post as a media file, making it the featured image.</li>
</ul>
<p>This code will automatically assign a default featured image for new or edited posts based on their category.</p>
<p><strong>Note</strong>: Make sure to test this code in a development environment before implementing it on your live site, and replace the example URLs with your actual default image URLs.</p>
<p>The post <a href="https://cneris.com/en/how-you-can-set-a-default-featured-image-for-each-post-category/">How you can set a default featured image for each post category</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/en/how-you-can-set-a-default-featured-image-for-each-post-category/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How can you create an autoresponder in WordPress that returns a jpg to the user whose content is generated from a form?</title>
		<link>https://cneris.com/en/how-can-you-create-an-autoresponder-in-wordpress-that-returns-a-jpg-to-the-user-whose-content-is-generated-from-a-form/</link>
					<comments>https://cneris.com/en/how-can-you-create-an-autoresponder-in-wordpress-that-returns-a-jpg-to-the-user-whose-content-is-generated-from-a-form/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sun, 27 Oct 2024 11:47:42 +0000</pubDate>
				<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[advanced form plugin]]></category>
		<category><![CDATA[autoresponder in wordpress]]></category>
		<category><![CDATA[custom image in wordpress]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2656</guid>

					<description><![CDATA[<p>Creating an autoresponder in WordPress that sends a custom JPG image generated from form data is possible, but requires a combination of PHP code and advanced plugins to handle both the form and the image generation. I'll explain the steps.   Install an Advanced Form Plugin Use a plugin like WPForms or Gravity Forms. These [...]</p>
<p>The post <a href="https://cneris.com/en/how-can-you-create-an-autoresponder-in-wordpress-that-returns-a-jpg-to-the-user-whose-content-is-generated-from-a-form/">How can you create an autoresponder in WordPress that returns a jpg to the user whose content is generated from a form?</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Creating an autoresponder in WordPress that sends a custom JPG image generated from form data is possible, but requires a combination of PHP code and advanced plugins to handle both the form and the image generation. I&#8217;ll explain the steps.</p>
<p>&nbsp;</p>
<ul>
<li><strong>Install an Advanced Form Plugin</strong><br />
Use a plugin like <strong>WPForms</strong> or <strong>Gravity Forms</strong>. These plugins let you create advanced forms that gather user data.</li>
<li><strong>Create a Code to Generate a Custom Image</strong><br />
In your theme’s <code>functions.php</code> file (preferably in a child theme), add a PHP code to generate an image based on form data:</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php">function generate_custom_image($data) {<br />
$image = imagecreatetruecolor(400, 200);<br />
$bg_color = imagecolorallocate($image, 255, 255, 255);<br />
$text_color = imagecolorallocate($image, 0, 0, 0);<br />
imagefill($image, 0, 0, $bg_color);<br />
imagestring($image, 5, 10, 10, "Name: " . $data['name'], $text_color);<br />
imagestring($image, 5, 10, 50, "Message: " . $data['message'], $text_color);<br />
$file_path = '/path/to/save/image.jpg';<br />
imagejpeg($image, $file_path);<br />
imagedestroy($image);<br />
return $file_path;<br />
}<br />
</code></div>
</div>
<p>Here, <code>$data</code> represents form data (e.g., <code>$data['name']</code> for the user’s name).</li>
<li><strong>Set Up the Autoresponder to Attach the Image</strong><br />
In WPForms or Gravity Forms, configure notifications to send an email to the user. Use the <code>generate_custom_image</code> function to create the file and attach it to the email.</li>
<li><strong>Testing and Adjustments</strong><br />
Make sure to test the form to confirm the JPG is generated and sent correctly.</li>
</ul>
<p>The post <a href="https://cneris.com/en/how-can-you-create-an-autoresponder-in-wordpress-that-returns-a-jpg-to-the-user-whose-content-is-generated-from-a-form/">How can you create an autoresponder in WordPress that returns a jpg to the user whose content is generated from a form?</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/en/how-can-you-create-an-autoresponder-in-wordpress-that-returns-a-jpg-to-the-user-whose-content-is-generated-from-a-form/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to create an autoresponder in WordPress that sends a PDF generated with the form data</title>
		<link>https://cneris.com/en/how-to-create-an-autoresponder-in-wordpress-that-sends-a-pdf-generated-with-the-form-data/</link>
					<comments>https://cneris.com/en/how-to-create-an-autoresponder-in-wordpress-that-sends-a-pdf-generated-with-the-form-data/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 26 Oct 2024 11:07:56 +0000</pubDate>
				<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[autoresponder in wordpress]]></category>
		<category><![CDATA[pdf generation]]></category>
		<category><![CDATA[pdf generator]]></category>
		<category><![CDATA[pdf plugin]]></category>
		<category><![CDATA[wpforms]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2568</guid>

					<description><![CDATA[<p>Install an Advanced Form Plugin Use a plugin like WPForms or Gravity Forms. Both allow advanced features and support for autoresponders and PDF. Create the Form Set up the necessary fields (such as name, email, etc.) with your chosen plugin. Install a PDF Generator You can use Gravity PDF (if using Gravity Forms) or a [...]</p>
<p>The post <a href="https://cneris.com/en/how-to-create-an-autoresponder-in-wordpress-that-sends-a-pdf-generated-with-the-form-data/">How to create an autoresponder in WordPress that sends a PDF generated with the form data</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<ul>
<li><strong>Install an Advanced Form Plugin</strong><br />
Use a plugin like <strong>WPForms</strong> or <strong>Gravity Forms</strong>. Both allow advanced features and support for autoresponders and PDF.</li>
<li><strong>Create the Form</strong><br />
Set up the necessary fields (such as name, email, etc.) with your chosen plugin.</li>
<li><strong>Install a PDF Generator</strong><br />
You can use <strong>Gravity PDF</strong> (if using Gravity Forms) or a PDF generation plugin like <strong>WPForms PDF Add-on</strong> for WPForms. These plugins allow you to create custom PDFs based on form data.</li>
<li><strong>Configure the Autoresponder</strong><br />
In the form plugin, enable auto-notifications to the user.</p>
<ul>
<li>For WPForms: Go to <strong>Settings</strong> &gt; <strong>Notifications</strong> and create a new notification addressed to the user&#8217;s email.</li>
<li>For Gravity Forms: Go to <strong>Form</strong> &gt; <strong>Settings</strong> &gt; <strong>Notifications</strong> and set up a notification to the user.</li>
</ul>
</li>
<li><strong>Attach the PDF</strong><br />
In the notification options:</p>
<ul>
<li>If using Gravity PDF, select the option to attach the automatically generated PDF.</li>
<li>If using WPForms, manually add the PDF if it is saved on the server.</li>
</ul>
</li>
<li><strong>Test the Form</strong><br />
Submit the form to ensure that the PDF is generated and attached correctly in the autoresponder email.</li>
</ul>
<p>The post <a href="https://cneris.com/en/how-to-create-an-autoresponder-in-wordpress-that-sends-a-pdf-generated-with-the-form-data/">How to create an autoresponder in WordPress that sends a PDF generated with the form data</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/en/how-to-create-an-autoresponder-in-wordpress-that-sends-a-pdf-generated-with-the-form-data/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
