WordPress Resources
Just got two useful links in my mail today
WordPRess 2.8 Cheat Sheet – All the useful template tags and functional reference you need for developing in WordPress 2.8
WPMU SPLOG Removal - Removing all of the nasty spam blogs and how to prevent them on your site.
Popularity: 2% [?]
Trouble with the Site Members Loop?
I have been having some trouble with the site members loop. Originally i had the template as normal, i simply changed the “type” variable to active for the widget loop. But what was heppening was the widget was being paginated aswell and only displaying the users that were on the Member-Directory column. ( Basically the widget was using the directories loop for information.)
The easiest way to overcome this error is to copy the widget code and place it in a file of its own, then simply call the file. I did that and got my loops to work independently.
Another thing to help would be to set the members directory loop to call all “alphabetical” users and not just the “active”, whats the point of having two loops calling recently active users.
Members Directory Files
Popularity: 2% [?]
Conversion Thank You page for BuddyPress Registration
I recently had to create a second step “Thank you” page for a client so they could add their Conversion Tracking code to it. Most people will simply add the tracking code to the registration page and set the URLs in your Conversion Tracking software.
Some tracking software programs have trouble when it comes to using the same url for the start and the conversion goal. Here’s what i did to create a “Thank You” page.
- Open up your theme folder and copy the register.php template
- Rename it to thank-you.php (or anything you want really)
- Next open up thank-you.php and paste the following into it right at the top (line 1) to create a static page template.
<?php /* Template Name: Thank You Template*/ ?>
- Log into your backend and create a static page called “Thank-you” and select the “Thank Your Template” from the list.
- Next open up the register.php and insert the following line straight after the call for the register form. This uses javascript to change the action of the form to send to the thank-you page.
<script type="text/javascript"> var changer = document.getElementById('setupform'); changer.action = 'http://yoursite.org.za/thank-you';</script>
- Lastly to make sure no one visits this page except during the registration process add the following lines of code just below the <body> tag
I have attached the two file register.php and thank-you.php so you can see how i did it.
Popularity: 2% [?]
Running quick tags outside of the loop
For anyone who has had the same frustration I have where you need tocall a function from a plugin, but they only have a quick tag you insert into the post/page.
Solution
<?php echo apply_filters(“the_content”,”[Insert Your Quick Tag Here]“); ?>
This will apply the filter that is usually applied when a post is queried, and display the quick tag as it would normall if you inserted via the backend.
Popularity: 2% [?]
Form Security
I recently learnt that there are two methods of bots messing around with forms on your website.
The following test is quoted from HTML Form Guide
a) As a relay for sending bulk unsolicited emails
If you are not validating your form fields (on the serve side) before sending the emails, then hackers can alter your email headers to send the bulk unsolicited emails. (also known as email injection) For example, hackers can place the following code in one of your form fields and make your form processor script send an email to an unintended recipient:sender@theirdomain.com%0ABcc:NewRecipient@anotherdomain.com
The code above is adding another email address to the CC list of the email. Spammers can send thousands of emails using this exploit. Your host will not be happy with this and may warn you or even ban your web site.
The best way to prevent this spammer exploit is to validate the fields used in the mail() function(fields like email, subject of the email, name etc). Check for the presence of any “new line” (\r\n) in those fields. The email form article contains sample code that does the same.
b) For Sending spam messages to youThere are programs known as ‘spam-bots’ that leech through the web pages looking for web forms. When found, those ‘bots’ just fills the fields with a spam message and submits. Eventually you will start getting many hundred submissions send by those spam bots and you will find it difficult to separate genuine submissions from spam messages.
The solution for this problem is to use a mechanism to identify human submitters from ‘bots’. CAPTCHA is one of such tests.
I have included two links in my Resources category to help against these two types of attack
Popularity: 2% [?]
Get just the logged in user url for BuddyPress
There are two functions here,
the first one will return the user url for a specified ID
function bp_core_get_justuserlink( $user_id, $no_anchor = false, $just_link = true, $deprecated = false, $with_s = false ) {
global $userdata;
$ud = get_userdata($user_id);
if ( !$ud )
return false;
if ( function_exists('bp_fetch_user_fullname') ) {
$display_name = bp_core_get_user_displayname( $user_id );
if ( $with_s )
$display_name = sprintf( __( "%s's", 'buddypress' ), $display_name );
} else {
$display_name = $ud->display_name;
}
if ( $no_anchor )
return $display_name;
if ( !$url = bp_core_get_userurl($user_id) )
return false; if ( $just_link )
return $url; return $url;
}
The second function will use the first, but get the url of the currently logged in user.
function bp_get_loggedinuser_link() {
global $bp;
if ( $link = bp_core_get_justuserlink( $bp->loggedin_user->id ) ) {
return $link;
}
}
Popularity: 2% [?]
Disable all caching on specific pages
Copy and paste this code into the template you want to disable caching on, usually used on activation pages if( is_object( $wp_object_cache ) ) $wp_object_cache->cache_enabled = false;
Popularity: 1% [?]
WordPress Hooks for Africa
All WordPress Hooks layed out nicely for you to look at.
Popularity: 1% [?]
Get just the link for the current logged in user
Any one who need to the the link for the current user. eg /member/admin or /member/warwick
Paste this code into the function.php for the theme and call it.
function bp_get_loggedinuser_link() {
global $bp;
if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) ) {
return apply_filters( 'bp_loggedinuser_link', $link );
}
}
Popularity: 1% [?]
Easily add conversion code to the registration process
Use this to add Google Adwords conversion script to your BuddyPress Install
google_adwords is the name on the function printing the code.
add_action(’signup_finished’,'google_adwords’);
Popularity: 1% [?]


