Pages

Showing posts with label Themes. Show all posts
Showing posts with label Themes. Show all posts

Saturday, December 29, 2012

Add Media Links in Activity Stream

Buddypress Media is a great plugin authored by rtCamp. They enable site users to upload media in albums. Media includes music, videos and photos.

However, the plugin lacks one important part - Adding media from the front end. Much like how another plugin Activity Plus does. Activity Plus lacks what BP Media provides - and that is - organizing into albums and having them stored for future use right on the members pages.

I thought of marrying both. i.e bringing BP media on the front-page where Activity Updates are posted.

//add media links

function add_media_links(){

    global $bp, $current_user;;

if (is_user_logged_in()) {

echo '<div style="float:right; font-weight:bold;">';

echo '<a href="'.$bp->root_domain . '/members/' . $current_user->user_login  .'/media/" style="color:black; padding-right:10px">Upload</a>';

echo '<a href="'.$bp->root_domain . '/members/' . $current_user->user_login  .'/albums/" style="color:black; padding-right:10px">My Albums</a>';

echo '<a href="'.$bp->root_domain . '/members/' . $current_user->user_login  .'/photos/" style="color:black; padding-right:10px">My Photos</a>';

echo '<a href="'.$bp->root_domain . '/members/' . $current_user->user_login  .'/videos/" style="color:black; padding-right:10px">My Videos</a>';

echo '<a href="'.$bp->root_domain . '/members/' . $current_user->user_login  .'/music/" style="color:black; padding-right:10px">My Music</a>';

echo '</div>';

}

else {

echo '<div style="float:right; font-weight:bold;">';

echo '<a href="'.$bp->root_domain . '/login/" style="color:black; padding-right:10px">Upload</a>';

echo '<a href="'.$bp->root_domain . '/login/" style="color:black; padding-right:10px">My Albums</a>';

echo '<a href="'.$bp->root_domain . '/login/" style="color:black; padding-right:10px">My Photos</a>';

echo '<a href="'.$bp->root_domain . '/login/" style="color:black; padding-right:10px">My Videos</a>';

echo '<a href="'.$bp->root_domain . '/login/" style="color:black; padding-right:10px">My Music</a>';

echo '</div>';}

return;

}

add_filter('bp_before_directory_activity_content',add_media_links');

?>
You may want to add this to your functions.php file.

This code, specially the last line of the code adds a filter such that whenever bp_before_directory_activity_content function is triggered, my own custom function add_media_links will trigger automatically where in, if the user is logged in, it provides direct links to the media upload as it takes $current_user->username to take them to their own page for media uploads. And if its just a visitor, these links will redirect to the login page.



You can see this in my site which is live in action at: DublinWala.Com

Monday, November 19, 2012

Automatically assign a different theme randomly for every new site in Wordpress Multisite

If you are the Multisite Super Admin of your Wordpress installation, then you must have felt the need to automatically assign a different theme for every new site that gets registered.

Currently what is happening in Wordpress Multi Sites is the same default theme that you initially assign will be used by all sites - and to me that's quite boring, especially when the admins of those sites do not change the default sites. It can also be an equally boring experience if you have disabled the Themes option for your sites and thus every user gets same theme.

Here is a simple trick from your wordpress kid:

  •  Step 1: Open wp-config.php file 
    • I'm sure you would know how to open this file. For those who don't please go to control panel of your hosting service provider where you can find the wordpress installation files. You wil find wp-config.php right in the root directory of your site.
  • Step 2: Just before the line which says "*/ That's all, stop editing! Happy blogging. */" paste this following code:
    • $theme1 =  'surface'; //theme1 folder name
       $theme2 = 'colorway'; //theme2 folder name
       $theme3 = 'amdhas'; //theme3 folder name
       $theme4 = 'swedish-grays'; //theme4 folder name
      
       $array = array($theme1, $theme2, $theme3, $theme4);
       $random_theme = $array[rand(0, count($array) - 1)];
      
       define('WP_DEFAULT_THEME', $random_theme);
  • Note that your theme folder names should be included in the variables $theme1, $theme2 etc. They are not theme names, but they are the folder names containing your themes. You can get these folder names in the wp-content/themes folder
  • Step 3: Sit back, take rest because you're done
    • The above code does the trick of assigning a random theme for every new user. 
If you face any difficulties, you could simple comment here and I will try to respond. That's two cents from Wordpress Kid. Thanks for reading.