<?xml version="1.0" encoding="UTF-8"?>
<rss 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/" version="2.0">

<channel>
	<title>Nutsmuggling</title>
	
	<link>http://davidebenini.it</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 03 Nov 2010 19:01:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Nutsmuggling" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="nutsmuggling" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>New Events Manager Website!!!</title>
		<link>http://davidebenini.it/2010/11/03/new-events-manager-website/</link>
		<comments>http://davidebenini.it/2010/11/03/new-events-manager-website/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 19:01:31 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Events Manager]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=604</guid>
		<description><![CDATA[Hey folks,
great news, there&#8217;s a new Events Manager Official Website!!!
There are new docs, a rich feature list and much more.
We plan to keep it updated and we already have a couple of tutorial in store, ready to be published.
Go check it out and make sure to subscribe to the RSS feed.
Cheers,
Davide
]]></description>
			<content:encoded><![CDATA[<p>Hey folks,<br />
great news, there&#8217;s a new <a href="http://wp-events-plugin.com/" onclick="javascript:pageTracker._trackPageview ('/outbound/wp-events-plugin.com');">Events Manager Official Website</a>!!!<br />
There are new docs, a rich feature list and much more.<br />
We plan to keep it updated and we already have a couple of tutorial in store, ready to be published.</p>
<p><a href="http://wp-events-plugin.com/" onclick="javascript:pageTracker._trackPageview ('/outbound/wp-events-plugin.com');">Go check it out</a> and make sure to subscribe to the RSS feed.</p>
<p>Cheers,<br />
Davide</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2010/11/03/new-events-manager-website/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Events Manager 3.0.2 is out, fixes major bugs</title>
		<link>http://davidebenini.it/2010/10/11/events-manager-3-0-2-is-out-fixes-major-bugs/</link>
		<comments>http://davidebenini.it/2010/10/11/events-manager-3-0-2-is-out-fixes-major-bugs/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 12:57:54 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Events Manager]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=602</guid>
		<description><![CDATA[If you&#8217;re using Events Manager, make sure you update version 3.0 or 3.0.1 to the latest version, as there was a major bug found in recurring events.
Marcus was alerted by a user, and was super fast in updating. 
Davide
]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using Events Manager, make sure you update version 3.0 or 3.0.1 to the latest version, as there was a major bug found in recurring events.</p>
<p>Marcus was alerted by a user, and was super fast in updating. </p>
<p>Davide</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2010/10/11/events-manager-3-0-2-is-out-fixes-major-bugs/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>EM 3.0.1 is out</title>
		<link>http://davidebenini.it/2010/10/10/em-3-0-1-is-out/</link>
		<comments>http://davidebenini.it/2010/10/10/em-3-0-1-is-out/#comments</comments>
		<pubDate>Sun, 10 Oct 2010 13:23:42 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Events Manager]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=600</guid>
		<description><![CDATA[Hello folks,
a short post to notify that Marcus has pushed out EM 3.0.1.
Luckily 3.0 was quite stable, and the are minor bugfixes, but do update! Here&#8217;s the change log:

Fixed spelling typos
Fixed warnings for bad location image uploads (e.g. too big etc.)
Fixed error for #_EXCERPT not showing  

Enjoy,
Davide
]]></description>
			<content:encoded><![CDATA[<p>Hello folks,<br />
a short post to notify that Marcus has pushed out EM 3.0.1.<br />
Luckily 3.0 was quite stable, and the are minor bugfixes, but do update! Here&#8217;s the change log:</p>
<ul>
<li>Fixed spelling typos</li>
<li>Fixed warnings for bad location image uploads (e.g. too big etc.)</li>
<li>Fixed error for #_EXCERPT not showing  </li>
</ul>
<p>Enjoy,<br />
Davide</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2010/10/10/em-3-0-1-is-out/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Events Manager 3.0 is out</title>
		<link>http://davidebenini.it/2010/10/07/events-manager-3-0-is-out/</link>
		<comments>http://davidebenini.it/2010/10/07/events-manager-3-0-is-out/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 09:25:20 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=595</guid>
		<description><![CDATA[Hello folks,
after months of apparent calmness Events Manager 3.0 is out.
So why the long wait?
Well, mostly because under the hood the plugin is completely new.
As you might remember Marcus jumped in a couple of versions ago adding the category and attribute features. Now he&#8217;s a co-maintainer, and he spent the last few months reorganizing the [...]]]></description>
			<content:encoded><![CDATA[<p>Hello folks,<br />
after months of apparent calmness <strong>Events Manager 3.0</strong> is out.</p>
<h3>So why the long wait?</h3>
<p>Well, mostly because under the hood the plugin is <em>completely new</em>.</p>
<p>As you might remember Marcus jumped in a couple of versions ago adding the category and attribute features. Now he&#8217;s a co-maintainer, and he spent the last few months reorganizing the EM code base. Events Manager 3.0 is quite similar to 2.2 on the outside, but everything has changed. Now it sports a modern, object-oriented, templated code base.</p>
<h3>What does this mean for users?</h3>
<p>Simple put, better support. Now that the code is tidy and modern it will be much easier to spot and fix bug. And it&#8217;ll be easier to add new stuff and mods.</p>
<h3>Can I upgrade safely?</h3>
<p>Indeed. EM 3.0 updates smoothly from 2.0. Still, if something goes wrong, we&#8217;ve made sure not to erase your old data, and&#8217;ve even included a &#8220;Migrate again&#8221; routine. If something wrong happens take a look at the new <em>Help</em> page, in the <em>Events</em> section of the menu.  </p>
<p>If you are using EM 1.*, you should first upgrade to 2.2, and then to 3.0.  </p>
<p>In any case it is always good practice to backup the your database before any upgrade.</p>
<h3>Is that all?</h3>
<p>Absolutely not, you will find out what&#8217;s ahed in the next few weeks. For now our focus is push 3.0 out, get your feedback and release 3.1 in a few weeks. Then&#8230; <em>surprise!</em>.</p>
<h3>BTW</h3>
<p>We&#8217;re here to stay <img src='http://davidebenini.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Davide and Marcus</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2010/10/07/events-manager-3-0-is-out/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to allow tags in Wordpress comments unobtrusively</title>
		<link>http://davidebenini.it/2010/04/29/how-to-allow-tags-in-wordpress-comments-unobtrusively/</link>
		<comments>http://davidebenini.it/2010/04/29/how-to-allow-tags-in-wordpress-comments-unobtrusively/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 10:31:08 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=580</guid>
		<description><![CDATA[How to allow tags in comments without touching the wp core]]></description>
			<content:encoded><![CDATA[<p>Scenario: I am using the <a href="http://wordpress.org/extend/plugins/tinymcecomments/">tinymcecomments</a> plugin to give some formatting capabilities to commenters.<br />
With the latest WP update I realised the <code>span</code> tag was removed from comments; colors attributes are filtered by the kses filter.</p>
<p>Hum.</p>
<p>After investigating I come across <a href="http://codex.wordpress.org/FAQ_Working_with_WordPress#How_do_I_stop_people_from_posting_HTML_in_comments.3F">this suggestion</a> in the Codex:</p>
<blockquote>
<p>Acceptance of HTML tags in the comments field is managed in the file kses.php, located in the wp-includes folder.</p>
<p>Open this file in a text editor, and locate the list of HTML tags near the top of the file. Each HTML tag is listed on a separate line, in the construction of a PHP array of allowed tags. Lines which begin with // are commented-out, or disabled, so lines which begin with // designate HTML tags that are not allowed in comments.</p>
<p>To stop people from posting HTML in comments, edit your kses.php file as desired to allow or disallow specific HTML tags in comments, by adding // to the very beginning of the appropriate lines of the list. To exclude all HTML tags, comment out all lines which allow HTML tags. Be sure to save your file when done.</p>
</blockquote>
<p>That&#8217;s a start but hey, is the Codex really suggesting that I alter the WP core? Next update my all precious settings will go away. C&#8217;mon, we can do better than that!</p>
<p>In the kses source code I find this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'CUSTOM_TAGS'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'CUSTOM_TAGS'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>CUSTOM_TAGS<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>     
	etc</pre></div></div>

<p>So basically I can redefine all the allowed tags structure in a constant. Not bad. But hey, do I really want to redefine  both the $allowedposttags and the $allowedtags variables? Naaah&#8230;</p>
<p>So I scavenged in the source code and I came across a fit filter. I wrote a little function for my functions.php file; needless to say, this could have gone into a plugin.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'preprocess_comment'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'fa_allow_tags_in_comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> fa_allow_tags_in_comments<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$allowedtags</span><span style="color: #339933;">;</span> 
	<span style="color: #000088;">$allowedtags</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'span'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'style'</span><span style="color: #339933;">=&gt;</span>array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$allowedtags</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'p'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>See? Much more concise than overwriting the variables. And more future-proof: if subsequent versions of Wordpress change the variable there is no constant barring the changes.</p>
<p>Cheers,<br />
Davide</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2010/04/29/how-to-allow-tags-in-wordpress-comments-unobtrusively/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Events Manager 2.2, security hole closed</title>
		<link>http://davidebenini.it/2010/04/10/events-manager-2-2-security-hole-closed/</link>
		<comments>http://davidebenini.it/2010/04/10/events-manager-2-2-security-hole-closed/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 15:26:00 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Events Manager]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=578</guid>
		<description><![CDATA[Security release of Events mMnager]]></description>
			<content:encoded><![CDATA[<p>Hello folks,<br />
I just released Events Manager 2.2. It&#8217;s a minor upgrade, here is the changelog:</p>
<ul>
<li>Added a option to get events through a select            </li>
<li>Closed many bugs causing a notices/warning visible only in debug mode</li>
<li>Closed a critical security hole discovered by Danilo Massa (to be released on May 10th)     </li>
</ul>
<p>The first point is the only proper feature, it allows you to use a select for the events venue. It&#8217;s something that comes in handy for people/organizations whose events take place in the same venues all the times.</p>
<p>The second point is something I should have done AGES ago. I put Worpress in debug mode and thus could see all the stuff that&#8217;s usually spitted directly into the error log. There were many small bugs, caused mainly by the lack of <code>isset</code> here and there. I believe there are still minor notice/warnings, but I got rid of most of them.</p>
<p>Point three is what urged me to release ASAP. <a href="http://www.danilomassa.info/dmportal/">Danilo Massa</a> kindly notified me of a security hole in Events Manager, providing a simple one-liner to fix it. Since the vulnerability is pretty serious I hurried to apply Danilo&#8217;s patch and release 2.2.</p>
<p>This release is quite stable, it&#8217;s employed in a client portal, so you should have no problem with the upgrade.</p>
<p>Enjoy,<br />
Davide</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2010/04/10/events-manager-2-2-security-hole-closed/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Atrio – Gestione Condomini</title>
		<link>http://davidebenini.it/2010/04/06/atrio-gestione-condomini/</link>
		<comments>http://davidebenini.it/2010/04/06/atrio-gestione-condomini/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 07:55:03 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Portfolio Entry]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=555</guid>
		<description><![CDATA[Atrio is a a team of professional focused on condominium management.
The Website has a fresh look, built upon the palette of teh Atrio logo.
The website is built with Webby; the end user is served a pure HTML version of the website, while ruby allows fast editing during the development.
]]></description>
			<content:encoded><![CDATA[<p>Atrio is a a team of professional focused on condominium management.<br />
The Website has a fresh look, built upon the palette of teh Atrio logo.<br />
The website is built with Webby; the end user is served a pure HTML version of the website, while ruby allows fast editing during the development.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2010/04/06/atrio-gestione-condomini/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Events Manager 2.1</title>
		<link>http://davidebenini.it/2010/03/04/events-manager-2-1/</link>
		<comments>http://davidebenini.it/2010/03/04/events-manager-2-1/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 18:54:59 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Events Manager]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=548</guid>
		<description><![CDATA[Hello folks,
just a short note to announce the release of Events Manager 2.1.
It&#8217;s probably not as stable as the lack of a or b would suggest, but it is definitely much stabler than the previous version. Also, I got tired of letters.
Here&#8217;s the changelog:

Properly added Marcus Sykes as a contributor  
Added a full calendar [...]]]></description>
			<content:encoded><![CDATA[<p>Hello folks,<br />
just a short note to announce the release of <a href="http://davidebenini.it/wordpress-plugins/events-manager/">Events Manager 2.1</a>.<br />
It&#8217;s probably not as stable as the lack of <code>a</code> or <code>b</code> would suggest, but it is definitely much stabler than the previous version. Also, I got tired of letters.</p>
<p>Here&#8217;s the changelog:</p>
<ul>
<li>Properly added Marcus Sykes as a contributor  </li>
<li>Added a full calendar  </li>
<li>Added an #_EDITEVENT placeholder  </li>
<li>Added Brazialian Portuguese localization and some translatable strings</li>
<li>Added a today scope for events lists</li>
<li>Increased to 3 te default lists limit</li>
<li>Categories are now displayed in the events table                        </li>
<li>Now weeks starts according to WP settings       </li>
<li>Moved the hide page option up for better access  </li>
<li>Attributes column was not created when the plugin was upgraded, fixed</li>
<li>Added comment field to the RSVP form and #_COMMENT placeholder in RSVP email templates </li>
<li>Added customizable title to small calendar      </li>
<li>Removed php short tags                        </li>
<li>Changed RVSP &#8216;no seats available message&#8217; for better English</li>
<li>Bugfix: there was a time bug</li>
<li>Bugfix: event_time not taken into consideration in ordering events, fixed</li>
<li>Bugfix: on calendar for days after 28  on the event calendar view</li>
<li>Bugfix: for events in days with single digit</li>
<li>Bugfix: events link in the calendar now work with permalink</li>
<li>Bugfix: today in next mont was not matched in the calendar </li>
<li>Bugfix: _RESPPHONE was not matched in emails</li>
<li>Bugfix: fixed security vulnerability, which could lead to sql inject attacks      </li>
<li>Bugfix: locations with apostrophe were duplicated</li>
<li>Bugfix: bloginfo(&#8216;wpurl&#8217;) instead of bloginfo(&#8216;url&#8217;)  </li>
<li>Bugfix: now loading textdomain in the new (not deprecated) way</li>
</ul>
<p>Most of the bugfixes, and some of the features, were sponsored by Sara of <a href="http://www.paperlantern.com/">Paperlantern</a>, to whom I am most grateful.</p>
<p>Also, I just got a haircut:</p>
<p><img src="http://davidebenini.it/wp-content/uploads/2010/03/Foto-del-61365666-03-2455260-alle-1702-300x225.jpg" alt="" title="Foto-del-61365666-03-2455260-alle-1702.jpg" width="300" height="225" class="aligncenter size-medium wp-image-547" /></p>
<p>Cheers,<br />
Davide</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2010/03/04/events-manager-2-1/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Wordpress: disable moderation for a single comment</title>
		<link>http://davidebenini.it/2009/12/16/wordpress-disable-moderation-for-a-single-comment/</link>
		<comments>http://davidebenini.it/2009/12/16/wordpress-disable-moderation-for-a-single-comment/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 11:47:13 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=531</guid>
		<description><![CDATA[I am working an very complex portal based on Wordpress. The more I code, the more I befriend the functions.php file, where all my small tweaks reside. Last in the list (pun!) a super simple action to automatically approve comments belonging to a specific post (which I use as a guestbook):

function approve_guestbook_comments&#40;$comment_ID&#41; &#123;
	$comment = get_comment&#40;$comment_ID&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>I am working an very complex portal based on Wordpress. The more I code, the more I befriend the <code>functions.php</code> file, where all my small tweaks reside. Last in the list (pun!) a super simple action to automatically approve comments belonging to a specific post (which I use as a guestbook):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> approve_guestbook_comments<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment_ID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$comment</span> <span style="color: #339933;">=</span> get_comment<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment_ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_post_ID</span> <span style="color: #339933;">==</span> guestbook_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		wp_set_comment_status<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment_ID</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'approve'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comment_post'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'approve_guestbook_comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As you see it&#8217;s a super-simple tweak, but it&#8217;s quite effective.</p>
<p>Enjoy,<br />
Davide</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2009/12/16/wordpress-disable-moderation-for-a-single-comment/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Mass import users into WP</title>
		<link>http://davidebenini.it/2009/11/30/mass-import-users-into-wp/</link>
		<comments>http://davidebenini.it/2009/11/30/mass-import-users-into-wp/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 18:04:09 +0000</pubDate>
		<dc:creator>Davide</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://davidebenini.it/?p=522</guid>
		<description><![CDATA[How to import a huge number of users into Wordpress]]></description>
			<content:encoded><![CDATA[<p>I am working on a complex blog/e-commerce system together with my colleagues at @ntw. I had to import some 10.000 users into WP. The task was easier than expected. The basic idea is leveraging on the <code>wp_insert_user($userdata)</code> function, defined in <code>wp-includes/registration.php</code>. If you look at the source, you&#8217;ll see that <code>$userdata</code> is an array containing a number of keys:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #339933;">*</span> The <span style="color: #000088;">$userdata</span> <span style="color: #990000;">array</span> can contain the following fields<span style="color: #339933;">:</span>
	<span style="color: #339933;">*</span> <span style="color: #0000ff;">'ID'</span> <span style="color: #339933;">-</span> An integer that will be used <span style="color: #b1b100;">for</span> updating an existing user<span style="color: #339933;">.</span>
	<span style="color: #339933;">*</span> <span style="color: #0000ff;">'user_pass'</span> <span style="color: #339933;">-</span> A string that contains the plain text password <span style="color: #b1b100;">for</span> the user<span style="color: #339933;">.</span>
	<span style="color: #339933;">*</span> <span style="color: #0000ff;">'user_login'</span> <span style="color: #339933;">-</span> A string that contains the user<span style="color: #0000ff;">'s username for logging in.
	* '</span>user_nicename<span style="color: #0000ff;">' - A string that contains a nicer looking name for the user.
	*		The default is the user'</span>s username<span style="color: #339933;">.</span></pre></div></div>

<p>The other keys are <code>user_url</code>,<code>user_email</code>, <code>display_name</code>, <code>nickname</code>, <code>first_name</code>, <code>last_name</code>, <code>description</code>, <code>rich_editing</code>, <code>user_registered</code>, <code>role</code>, <code>jabber</code>, <code>aim</code>, <code>yim</code>; for more detal consult the source itself.</p>
<p>My script goes like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'wp-blog-header.php'</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'wp-includes/registration.php'</span><span style="color: #339933;">;</span>   
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'wp-includes/pluggable.php'</span><span style="color: #339933;">;</span> 
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;memory_limit&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;1024M&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;max_execution_time&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;240&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;h1&gt;Importazione utenti EC&lt;/h1&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$connection</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;host&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;user&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Unable to connect to MySQL&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;database&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$connection</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Unable to connect to the database&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM source_users ;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;strong&gt;ID:&lt;/strong&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &lt;strong&gt;login:&lt;/strong&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &lt;strong&gt;password:&lt;/strong&gt; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">password</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &lt;strong&gt;e-mail:&lt;/strong&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">email_address</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &lt;strong&gt;name:&lt;/strong&gt; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &lt;strong&gt;surname:&lt;/strong&gt; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">surname</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span>  
		<span style="color: #666666; font-style: italic;">// Add the ID to trick WP</span>
		<span style="color: #000088;">$add_id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">users</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; (id, user_login) VALUES (&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;,'&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$row-&gt;user_name</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;' ); &quot;</span><span style="color: #339933;">;</span>
		 <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$add_id</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// Add the rest</span>
		<span style="color: #000088;">$userdata</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		 <span style="color: #0000ff;">'ID'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">,</span>  
		 <span style="color: #0000ff;">'user_login'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_name</span><span style="color: #339933;">,</span>
		 <span style="color: #0000ff;">'user_pass'</span> <span style="color: #339933;">=&gt;</span> wp_hash_password<span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		 <span style="color: #0000ff;">'user_nicename'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_name</span><span style="color: #339933;">,</span>
		 <span style="color: #0000ff;">'user_email'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">email_address</span><span style="color: #339933;">,</span>
		 <span style="color: #0000ff;">'first_name'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">,</span>
		 <span style="color: #0000ff;">'last_name'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">surname</span><span style="color: #339933;">,</span>
		 <span style="color: #0000ff;">'role'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'subscriber'</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                          
		wp_insert_user<span style="color: #009900;">&#40;</span><span style="color: #000088;">$userdata</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connection</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Some highlights:</p>
<ul>
<li>Import all the WP files you need </li>
<li>Change PHP memory and time limits if you have many records</li>
<li>Explicitly encrypt the password with <code>wp_hash_password</code>. I have no idea why this is necessary, the WP code should do this by itself; but trust me, it is.</li>
</ul>
<p>Since we are using the <code>wp_insert_user()</code> function, WP will crate records both in the users and in the usermeta tables.</p>
<p>A last warning. This huge amount of users could conflict with your php settings. To get WP working properly I had to add this line to <code>wp-config.php</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_MEMORY_LIMIT'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'64M'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Without it I could not get the users list in the admin session. I also <a href="http://core.trac.wordpress.org/ticket/11151">filed a bug</a>, but this last line should keep you on the safe side.<br />
Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://davidebenini.it/2009/11/30/mass-import-users-into-wp/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss><!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->

