Skip to content

Instantly share code, notes, and snippets.

//How to edit a user profile on the front end?
//http://wordpress.stackexchange.com/questions/9775/how-to-edit-a-user-profile-on-the-front-end
//Forcing nickname as display_name in custom edit profile template
//http://wordpress.stackexchange.com/questions/35403/forcing-nickname-as-display-name-in-custom-edit-profile-template
///////
<?php
@fritids
fritids / gist:6818054
Created October 3, 2013 22:22
Show something ifwp user meta is empty
//first you need to get the current author of the page
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name);
else :
$curauth = get_userdata(intval($author));
endif;
//then your condition
if(!empty($curauth->website)){
//shows the website
<?php
// Processing Section
global $current_user, $wp_roles;
get_currentuserinfo();
/* Load the registration file. */
require_once( ABSPATH . WPINC . '/registration.php' );
/* If profile was saved, update profile. */
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'update-user' ) {
<?php
global $current_user;
get_currentuserinfo();
echo 'Username: ' . $current_user->user_login . "\n";
echo '<br />';
echo 'User first name: ' . $current_user->user_firstname . "\n";
echo '<br />';
echo 'User last name: ' . $current_user->user_lastname . "\n";
echo '<br />';
echo 'User display name: ' . $current_user->display_name . "\n";
<?php
function sce_create_page($user_id){
$the_user = get_userdata($user_id);;
$new_user_name = $the_user->user_login;
$my_post = array();
$cat_name = wp_create_category('premium');
$my_post['post_title'] = $new_user_name . $cat_name;
$my_post['post_type'] = 'post';
$my_post['post_content'] = '';
$my_post['post_status'] = 'publish';
<?php
/*
Plugin Name: Mingle - Users - Online (example)
Description: Requires WP-UserOnline to be installed
*/
function mingle_linked_names( $name, $user ) {
if ( !$user->user_id ) {
return $name;
}
<?php
function wpr_authorNotification($post_id) {
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$message = "
Hi ".$author->display_name.",
Your post, ".$post->post_title." has just been published. Well done!
";
wp_mail($author->user_email, "Your article is online", $message);
<?php
function getTweets($hash_tag) {
$url = 'http://search.twitter.com/search.atom?q='.urlencode($hash_tag) ;
echo "<p>Connecting to <strong>$url</strong> ...</p>";
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
$xml = curl_exec ($ch);
curl_close ($ch);
<?php
function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2) {
$theta = $longitude1 - $longitude2;
$miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)));
$miles = acos($miles);
$miles = rad2deg($miles);
$miles = $miles * 60 * 1.1515;
$feet = $miles * 5280;
$yards = $feet / 3;