WordPress Activation Key
This is how WordPress uses the new user ID and an MD5 hash to generate the activation key
$newuser_key = substr( md5( $user_id ), 0, 5 );
Popularity: 1% [?]
WordPress/BuddyPress – Meta title tag not working
If your buddypress child theme or customized parent theme does not work properly, in otherwords does you title tag output “[Blogname] – Blog” then use the code below to remedy the error.
Whats happening is if you use bp_title_tag() is will output the default string as seen above. If you lean towards using the WordPress conditional tags to test the pages, WordPress will see the BuddyPress pages as normal static pages.
Using bp_get_title_tag we can test to see if its a WordPress page or a BuddyPress page and use the appropriate title tag.
<title><?php
if ( is_home() ) { bloginfo('name'); echo ' | '; bloginfo('description'); }
elseif ( is_search() ) { bloginfo('name'); echo ' | '; _e('Search Results'); }
elseif ( is_author() ) { bloginfo('name'); echo ' | '; _e('Author Archives'); }
elseif ( is_single() ) { bloginfo('name'); echo ' | '; wp_title(''); }
// Entering the buddypress tags
elseif ( is_page() ) {
$page_title = rtrim(ltrim(bp_get_page_title()));
if ( $page_title == "[INSETRT YOUR WP_TITLE HERE] — Blog" ) { bloginfo('name'); echo ' | '; wp_title('');}
else{ bp_page_title(); }
}
elseif ( is_category() ) { bloginfo('name'); echo ' | '; _e('Archive'); echo ' | '; single_cat_title(); }
elseif ( is_month() ) { bloginfo('name'); echo ' | '; _e('Archive'); echo ' | '; the_time('F'); }
elseif (function_exists('is_tag')) { if ( is_tag() ) { bloginfo('name'); echo ' | '; _e('Tag Archive'); echo ' | '; single_tag_title("", true); } }
else { } ?></title>
Popularity: 10% [?]
Login Redirect to your Buddypress user profile on login
Using the Login Redirect plugin by Login Redirect, which can be found at http://premium.wpmudev.org/project/login-redirect
As this is a paid for plugin I will only be placing the line i changed to achive what i wanted.
First change the login redirect url var to /members/ ( Line 32 )
$login_redirect_url = '/members/.$_POST['log']'; // the url you want users to be redirected too after logging in
The $_POST['log'] var is the username that was posted from the User Login form to the next page. This is just a basic implementation, if you have Facebook connect, OpenID etc you will have to put in some variations for that.
Popularity: 3% [?]
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% [?]


