Role Worksheet

//Update user role
$u = new WP_User( 26 );
$u->remove_role( 'editor' );
$u->add_role( 'customrole' );

//Add new custom role
add_role('customrole', 'Customrole',array('read' => 1,'level_0' => 1,'access_level_0' => 1,'access_level_1' => 1));

//Remove Role
remove_role('customrole');

//Add capability
global $wp_roles;
$wp_roles->add_cap('customrole','access_level_1');

Server Superglobal

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Server Superblogal</title>

</head>
<body>

<?php

get_server_superglobals();

function get_server_superglobals(){?>
<style type="text/css">
.superglobals{font-family:"Courier New", Courier, monospace; font-size:14px; padding:8px;}
.superglobals tr td{border:1px solid #E4E4E4; padding:2px 6px; margin-right:10px;}
.superglobals tr th{border:1px solid #444; padding:2px 6px; margin-right:10px; background-color:#ccc;}
.superglobals tr:hover td{background-color:#E4E4E4;}
.superglobals .snippet{font-size:10px;}
.superglobals .middle{width:500px; overflow:auto;}
</style>
<?php
$constants = array(
'argv',
'argc',
'AUTH_TYPE',
'DOCUMENT_ROOT',
'GATEWAY_INTERFACE',
'HTTP_ACCEPT',
'HTTP_ACCEPT_CHARSET',
'HTTP_ACCEPT_ENCODING',
'HTTP_ACCEPT_LANGUAGE',
'HTTP_CONNECTION',
'HTTP_COOKIE',
'HTTP_HOST',
'HTTP_IF_MODIFIED_SINCE',
'HTTP_KEEP_ALIVE',
'HTTP_REFERER',
'HTTP_USER_AGENT',
'HTTPS',
'ORIG_PATH_INFO',
'PATH',
'PATH_INFO',
'PATH_TRANSLATED',
'PHP_AUTH_DIGEST',
'PHP_AUTH_USER',
'PHP_AUTH_PW',
'PHP_SELF',
'QUERY_STRING',
'REDIRECT_STATUS',
'REMOTE_ADDR',
'REMOTE_HOST',
'REMOTE_PORT',
'REQUEST_METHOD',
'REQUEST_TIME',
'REQUEST_URI',
'SCRIPT_FILENAME',
'SCRIPT_NAME',
'SERVER_ADDR',
'SERVER_ADMIN',
'SERVER_NAME',
'SERVER_PORT',
'SERVER_SIGNATURE',
'SERVER_SOFTWARE',
'SERVER_PROTOCOL',
'UNIQUE_ID',
);
?>

<table class="superglobals">
<tr>
<th>Constant</th>
<th><div class="middle">Server Superglobal Output</div></th>
<th>Snippet</th>
</tr>
<?php
foreach($constants as $constant){?>
<tr>
<td><strong><?php echo $constant ?></strong></td>
<td><div class="middle"><?php echo $_SERVER[$constant] ?></div></td>
<td class="snippet"><?php echo "$_SERVER['" . $constant . "']" ?></td>
</tr>
<?php
}
?>
</table>
<?php
}
?>

</body>
</html>

BP global worksheet

<?php
function bp_dump() {
global $bp;

foreach ( (array)$bp as $key => $value ) {
echo '<pre>';
echo '<strong>' . $key . ': </strong><br />';
print_r( $value );
echo '</pre>';
}
die;
}
add_action( 'wp', 'bp_dump' );
?>

<?php //Main Worksheet ~~~~~~~~~~~~~~~~~
//Call the global
global $bp;

// Displays the current component, like activity, members etc.
echo 'Current Component = ' . $bp->current_component;

// Displays the current action within the members window, like friends, mentions, anything in the ajax window.
echo 'Current Action = ' . $bp->current_action;

// Displays the current users profile URL.
echo 'Profile URL = ' . $bp->displayed_user->domain;
?>

Category and Post ID worksheet

<?php
 // This function retreives category ID from an archive page
 function getCurrentCatID(){ 
  global $wp_query; 
  if(is_category() || is_single()){ 
   $cat_ID = get_query_var('cat');
  } 
   return $cat_ID; 
 } 
 echo 'Function Category ID = ';
 echo getCurrentCatID();
 
 echo 'Function Category ID = ' . get_query_var('cat');
 ?>
    
    <br />
 
 
 <?php
 //This retreives category ID from an archive page
 echo 'Cat = ' . get_query_var('cat');
 ?>
  
 <br />
  
  
   <?php
   //The Category ID - In and Out (Use False to prevent echo) *only works for child category
   echo 'Category ID = ';
   the_category_ID( );
   ?>

      <br />
     
      <?php echo 'Category Name = ' . get_cat_name(the_category_ID(false)); ?>
     
      <br />

      <?php
   if (cat_is_ancestor_of( 53 , the_category_ID(false))){
  echo 'In Category 53? = Yes';
   } else echo 'In Category 53? = No';
   ?>
     
      <br />
     
      <?php //$post-> ID - In and Out
   echo 'Post ID = ' . $post->ID;
   ?>
     
      <br />
     
      <p>Begin WordPress Loop</p>
     
     
     
      <!-- ~~~~~~~~~~~~~~ The Loop ~~~~~~~~~~~~~~~ -->
     
      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
     
   
     
      <?php //Get The ID - Loop Only
   echo 'Post ID = ' . get_the_ID();
   ?>
  
   <br />
  
   <?php //The ID - Loop Only (Use False to prevent echo)
   echo 'Post ID = ';
   the_ID();
   ?>
  
   <?php endwhile; endif; ?>