Category Archives: WordPress

All things WordPress on Linux. I don’t do WP on Windows as there is no point. If you have a licenced Windows server install Hyoer-V and run up a virtual linux system for apps like WordPress. Its a much more robust process than trying to make Windows do things it was never designed to do.

(Solved!) NextGEN Gallery works only with a role….

WordPress, MultiSite, NextGEN Gallery and this annoying message “Sorry, NextGEN Gallery works only with a role called administrator.”

Dashboard Error Nextgen Gallery WordPress Multisite

NextGEN Gallery error Administrator role

I noted a lot of older posts on the WordPress support site that lead nowhere to find a resolution, or, as someone else posted, they went poof! into a bug report hidden from the public.

Have I really solved this issue ? Yes, for the specific site that I am working on. Will this be the same issue for you? Maybe not, but here are the details.

So to be clear I am using the latest WordPress version and the latest NextGEN Gallery version in a multi-site configuration with about 6 sites within it. The nature of the issue is that the stated error message persists in the dashboard / admin view for a sub-site. It was not all sub-sites and when I did a proper review it was in fact only in one sub-site that the error displayed.

So I checked the php script just to confirm that the error message was telling the truth or at least was not a case of poor translation and it wasn’t. The actual script is at the bottom of this post but it is not relevant beyond confirming that it is a ‘role’ issue.

Wordpress Multisite Users Panel with no users

There were no users for the sub-site

Next I questioned, if I am the administrator for the main site and most of the sub-sites, why is there no administrator role?

Sure enough a check of the Users page for all the sites revealed that I was correctly in that role for all but the site that was giving the error.

This is where it got tricky, the sub-site was the #2 sub-site and the oldest sub-site, aside from the main site and when I tried to add an existing user or a new user to the subsite it completed but still did not show a user.

Empty WordPress Roles

The role dropdown is not populated.

The Role drop-down was not populating and therefore the concept of administrator was not available to be set for the user.

I experimented for a while with different settings, comparing sub-sites and trying to fathom why this was happening. The end result was no reason for it, other than I think this original blog #2 may have pre-dated a major upgrade in WordPress Multisite and perhaps there was some artifact or setting missing as a result.

In any case, I did a backup of the database, created a new subsite, ran an export of the #2 subsite, ran an import of the same data into the new subsite, and bingo!  There is now a new user with a role of Administrator and the NextGen error is no longer appearing.

The final clean up was to rename the old #2 site and archive it. Then rename the new site to the same as the old one, tweak the settings for theme, menu, widgets, and url, and the transition was done. All up this should take you less than 15 minutes to do.

Does it resolve the actual issue, no, but I think the error is not actually a NextGEN issue, but an issue with the WordPress site. If you have read this far, you probably have a similar problem, I hope this works for you.

 

NextGen nggallery_install Function

Now dont panic, the following code is just for my records, there is no need to change it. This is the piece of the PHP function that generates the error and I include it here just to confirm that the error is generated when there is not an available administrator role for the site.

	// Set the capabilities for the administrator
	$role = get_role('administrator');
	// We need this role, no other chance
	if ( empty($role) ) {
		update_option( "ngg_init_check", __('Sorry, NextGEN Gallery works only with a role called administrator',"nggallery") );
		return;
	}

	$role->add_cap('NextGEN Gallery overview');
	$role->add_cap('NextGEN Use TinyMCE');
	$role->add_cap('NextGEN Upload images');
	$role->add_cap('NextGEN Manage gallery');
	$role->add_cap('NextGEN Manage tags');
	$role->add_cap('NextGEN Manage others gallery');
	$role->add_cap('NextGEN Edit album');
	$role->add_cap('NextGEN Change style');
	$role->add_cap('NextGEN Change options');

NextGen Gallery image file name change thumbnail error occurred

The NextGen Gallery is one of the plugins that I use on lots of WordPress sites.

I’d never struck this before and the information from all the blogs and forum posts I looked at did not or could not resolve how to fix this issue.

The situation arises when you rename an image file directly in the file manager, or in my case the linux command line. The filename is actually stored in the database in the wp_ngg_pictures table and for manual correction you would expect that updating the filename column would be sufficient.

Then selecting the image and the recreate thumbnail option is expected to do just that, but it doesn’t. You may see an “error occurred” message in the thumbnail creation screen but it is not a helpful message.

The issue is in fact that the thumbnail details are stored in another column called metadata in the same table and this column is referenced for the thumbnail update and not the filename, i.e. NGG is still the original thumbnail filename and recreating that file not the new file.

There are two steps required, change the filename in that column and delete the metadata field value back to null or empty. Then you can re-create your thumbnails and they will work with the new filename.

Which WordPress Contact Form Plugin to use?

Reviewing the plethora of Contact Form plugins for WordPress is daunting.  I have looked at dozens of possible options.

This review is relatively brief and focuses on obvious contenders. The rest can be summarily dismissed:

Contact Form by ContactMe.com reads very well, with all the common features. The catch is that it requires registration at yet another software as a service provider that wants your name and email address and offers ‘features’ that are totally unneccessary for the purpose of a contact form. Not for me.

Custom Contact Forms is another that sounds promising when reading the blurb and it installs smoothly, but then the top line is “Are you looking for a more customizable, reliable, and secure contact form solution for WordPress? Try Gravity Forms” which says to me that this plugin is not reliable or secure or customisable? Just a weird approach to marketing. Did not go further as Gravity Forms is one I am also looking at and if this one promotes Gravity then who am I to argue?

Fast Secure Contact Form is anything but fast with screen after screen of options, fields, and settings in one very long page. While I started to trawl down the list, I was overwhelmed within 30 seconds and decided that it would require far too much thinking and effort when all I want is a simple ‘Contact Us’ page.

BotDetect CAPTCHA is not a contact form tool but a method of adding Captcha processes to an entire WordPress site. The issue is that the plugin install does not include the native Captcha library, which must be downloaded separately and only after registering your email address with the service provider, etc. I had hoped to build a contact form and add this, but it just gave me headaches trying to get it configured.

Contact Form With Captcha is a nice contact form but the Recaptcha process is difficult for some users as the distortion of the words can be too much. In fact I have deployed this one on a number of sites and this review is simply to find an alternative that provides flexibility in the Captcha options.

Contact Form 7 is the one I eventually went with as it provided an easier Captcha option.

 

Turning off WordPress redirects index.php to index.html on Cpanel Apache

I spent a bit of time today trying to research why Apache on Cpanel insisted on redirecting from index.php when it was entered as an explicit URL to the default index.html page in the website home directory.

As it turned out, while I am searching for “cpanel apache redirects” I should have been asking “Why does WordPress redirect…” and that change of question led me to this WordPress forum thread that addressed the actual issue.

Now normally I would not repeat the information here, but just in case that link disappears, I do want to be able to get to it again, so here it is.

The issue actually is not Apache or Cpanel driven, but is an issue with WordPress and the way that it redirects all requests to the home page for the site. Hence despite me trying to access index.php, WordPress was redirecting to index.html, and that prevented me from seeing the new WP site.

Ultimately the purpose of this was to allow for WordPress to be installed alongside an existing page based site and deploy for final user acceptance before switching off the old site and moving to WordPress as the new site.

The trick is simply a manually installed plugin that can be removed after final commissioning to production.

1. Open your site with an FTP program or SSH depending on you preference

2. Navigate to yoursite_folder/wp-content/plugins/

3. Create a new folder for the plugin – call it disable-canonical-redirects – or dcr for short

4. Change to that folder

5. Create a new index.php file and include (copy and paste or re-type) this PHP code into that file:

<?php
/*
Plugin Name: Disable Canonical URL Redirection
Description: Disables the "Canonical URL Redirect" features of WordPress 2.3 and above.
Version: 1.0
Author: Mark Jaquith
Author URI: http://markjaquith.com/
*/

remove_filter('template_redirect', 'redirect_canonical');
?>

5. Visit your WordPress Admin backend and activate this new plugin

6. All is now good to go and access index.html by default or index.php for WordPress explicitly.

Many thanks to Mark and others in that discussion thread.