User Photo plugin not working? – try this…
Once again, I recently ran into a situation where something cool that I was developing worked just fine when run locally using MAMP. But then, when i uploaded everything to my server, things did not work as expected.
This will be a short one.
In this case I am using the User Photo plugin v.0.9.4 and WordPress v.3.0.4. I have a place on my single post page(s) (single.php) where I want to show a tumbnail of the author’s photo using the following code…
<?php userphoto_the_author_thumbnail(); ?>
…and it just was not working. After doing the usual bit of googling, I discovered this thread on the WordPress support forums where I found my solution (thanks to user “dragunoff”). It turns out the issue is apparrently linked to wether or not a user photo should be held for moderation or not depending on their user level.
the fix…
At approximately line 120 in the User Photo plugin file “user-photo.php”, located at /wp-content/plugins/user-photo/, there is a function called “userphoto__get_userphoto”. About 3 or 4 lines down in that function you’ll see this line of code…
if(($userdata->userphoto_approvalstatus == USERPHOTO_APPROVED) &&
All we need to do is add 2 forward slashes – “//” – after the first open parentheses to comment out this first condition in the “if” statement, like so…
if( // ($userdata->userphoto_approvalstatus == USERPHOTO_APPROVED) &&
…and all should work fine.
What we’re really doing is removing the check for approval status from administrator moderation. So, don’t use this hack if you have a site where users could potentially upload some “questionable” user photos.
update: 02.18.11 – this also works with User Photo plugin v.0.9.5 and WordPress v.3.0.5.
get the top parent category in WordPress
Here’s a cool little scrap of code to get the name of the top parent category in WordPress. This is another one of those things i spent a good deal of time trying to find through a lot of web searching. I finally came across a post somewhere (can’t remember where anymore) which had the solution I was looking for. I’ve just changed some of the wording (for my own benefit) and have posted it here. This will get the top parent category name, no matter how many levels deep in the category heirarchy you might be. To get this up and running, just add the code below to your functions.php file…
<?php
function get_parent_category_name($cat) {
$parentCategoryList = get_category_parents($cat, false, ',');
$parentCategoryListArray = split(',', $parentCatList);
$parentName = $parentCategoryListArray[0];
$stuffToReplace = array(' ' => '-', '(' => '', ')' => '');
$parent = strtolower(strtr($parentName,$stuffToReplace));
return $parent;
}
?>
Then, put this bit in your template where you want to place the top parent category name…
<?php get_parent_category_name($cat); ?>
This function returns the category “slug”.
To return the actual category name, replace the last line in the block of code above with this…
return $parentName;
Have fun…
WordPress & bbPress integration login trouble?
I was just recently working on a project where i was building a new WordPress site and was adding a “forums” section powered by bbPress. I followed all of the instructions provided on the bbPress site – here.
I installed the “bbPress Integration” plugin and filled in all of the proper fields in the “bbPress Integration” screen under “Settings” in the WordPress admin. Likewise, I completed all of the necessary fields on the “WordPress Integration” screen under “Settings” in the bbPress admin. I then made sure to open up both of my config files (config.php for WordPress and bb-config.php for bbPress) and ensured that they had all of the proper matching keys/strings filled in for all of the “SALT” and “AUTH” values, etc., etc. – but no matter what i tried, I couldn’t get logins across both areas of the site to work. The cookies were not being used/written/shared across both platforms like they are supposed to if you do everything correctly.
When I logged into WordPress and then switched over to the bbPress-powered forums I discoverd that I was now logged out. Then I logged in to the bbPress-powered forums and switched over to the WordPress site and I was logged out again. I couldn’t get it remember/use/recognize the same cookies across both applications and it was driving me crazy.
What made matters worse is that this all worked perfectly on my local dev environment – running a MAMP server on my Mac.
Then, FINALLY, I stumbled across a few snippets here and there after doing A LOT of googling that mentioned an issue where using 64-character keys seemed to be the problem. Several users mentioned that switching the keys (SALT, AUTH values, etc.) to 32-character values seemed to make things work properly. So, i tried it and all of a sudden, everything now worked!
Whenever I come across a strange problem (like this one) that takes me hours to figure out, I try to make the effort to then share the solution here, so that others don’t have to go through the same hell as me.
So, to give you an example – take the code that contains your keys in your WordPress config.php file…
define('AUTH_KEY', '/xhuN*9-eSK//l}W-a=21z*+i6iz@N-6kWlTah[{gh}7{`%T~&B-HrYr5pgP+OxN');
define('SECURE_AUTH_KEY', 'l9jwMX2U*+:sSzQo~8OOt}!54*1KV@:
define('LOGGED_IN_KEY', '!]-^))}7PB_IZ+kzZV?H@sXvRC[K?:![lsd<6=4;UMKL_%Il%-axHv4*[g20m*g^');
define('NONCE_KEY', '!.OW{67^@=BM-THdr`2i<2qH,t_|/7$|-nUw4+os8n@*[ZF/nnHc`c%vsI~hM?2#');
define('AUTH_SALT', 'Jiz70.vxul~rpgfA#ll?:t24rF
define('LOGGED_IN_SALT', '4+NR?-=*ykRsY~:mqj`5#9!=hRfSi<#&C%nLS&u^p/JuPar)#Uj(j91JG|ThKjfY');
define('NONCE_SALT', 'sF=0{^1Y&WxIyd1Zc{*7&V~v+y6j0V0A}#R==J,-Ql8t[$+ :jV-t5PR~xA+[M%U');
and shorthen the 64-character strings down to 32-character strings, like so...
define('AUTH_KEY', '/xhuN*9-eSK//l}W-a=21z*+i6iz@N-6');
define('SECURE_AUTH_KEY', 'l9jwMX2U*+:sSzQo~8OOt}!54*1KV@:<');
define('LOGGED_IN_KEY', '!]-^))}7PB_IZ+kzZV?H@sXvRC[K?:![');
define('NONCE_KEY', '!.OW{67^@=BM-THdr`2i<2qH,t_|/7$|');
define('AUTH_SALT', 'Jiz70.vxul~rpgfA#ll?:t24rF
define('LOGGED_IN_SALT', '4+NR?-=*ykRsY~:mqj`5#9!=hRfSi<#&');
define('NONCE_SALT', 'sF=0{^1Y&WxIyd1Zc{*7&V~v+y6j0V0A');
Then, in your bbPress bb-config.php file...
define('BB_AUTH_KEY', '/xhuN*9-eSK//l}W-a=21z*+i6iz@N-6kWlTah[{gh}7{`%T~&B-HrYr5pgP+OxN');
define('BB_SECURE_AUTH_KEY', 'l9jwMX2U*+:sSzQo~8OOt}!54*1KV@:
define('BB_LOGGED_IN_KEY', '!]-^))}7PB_IZ+kzZV?H@sXvRC[K?:![lsd<6=4;UMKL_%Il%-axHv4*[g20m*g^');
define('BB_NONCE_KEY', '!.OW{67^@=BM-THdr`2i<2qH,t_|/7$|-nUw4+os8n@*[ZF/nnHc`c%vsI~hM?2#');
define('BB_AUTH_SALT', 'Jiz70.vxul~rpgfA#ll?:t24rF
define('BB_LOGGED_IN_SALT', '4+NR?-=*ykRsY~:mqj`5#9!=hRfSi<#&C%nLS&u^p/JuPar)#Uj(j91JG|ThKjfY');
define('BB_NONCE_SALT', 'sF=0{^1Y&WxIyd1Zc{*7&V~v+y6j0V0A}#R==J,-Ql8t[$+ :jV-t5PR~xA+[M%U');
do the same thing - shorthen the 64-character strings down to 32-characters...
define('BB_AUTH_KEY', '/xhuN*9-eSK//l}W-a=21z*+i6iz@N-6');
define('BB_SECURE_AUTH_KEY', 'l9jwMX2U*+:sSzQo~8OOt}!54*1KV@:<');
define('BB_LOGGED_IN_KEY', '!]-^))}7PB_IZ+kzZV?H@sXvRC[K?:







