Skip to content

Instantly share code, notes, and snippets.

<a href="mailto:%%meta_email%%">%%meta_email%%</a>
<a href="%%meta_website%%">%%meta_website%%%</a>
@sareiodata
sareiodata / gist:3416524
Created August 21, 2012 15:24
Change the Email users receive after registration
function pb_custom_email(){
$content = <<<EOD
<h1>Hello to our site</h1>
<p>Something interesting to tell to our new registered user</p>
<img src="https://www.google.com/images/srpr/logo3w.png" alt="the google logo" />
EOD;
return $content
}
add_filter("wppb_register_email_content", "pb_custom_email");
function pb_send_email_on_profile_update($user_id, $old_user_data){
$message = "$user_id updated their profile";
wp_mail('me@example.net', 'The subject', $message);
}
add_action("profile_update", "pb_send_email_on_profile_update", 10, 2);
@sareiodata
sareiodata / gist:3775708
Created September 24, 2012 12:27
WordPress Oembed.
function oembed_filter( $content) {
global $wp_embed;
add_filter( 'embed_oembed_discover', '__return_false', 999 );
$comment_text = $wp_embed->autoembed( $content );
remove_filter( 'embed_oembed_discover', '__return_false', 999 );
return $content;
}
add_filter( 'the_content', 'oembed_filter');
function osu_author_bio($value, $user_id) {
return nl2br($value); // this PHP function should read newlines (n) and output HTML breaks
}
add_filter('get_the_author_description', 'osu_author_bio', 10, 2);
$current_user = wp_get_current_user();
if ( 0 == $current_user->ID ) {
// Not logged in. Can't comment
} else {
$birthday = get_user_meta($current_user->ID, 'birthday-your-unique-slug', true);
if ($birthday >= 18) {
//display comment form
} else {
// DO NOT display comment form
}
@sareiodata
sareiodata / gist:3952655
Created October 25, 2012 13:51
custom walker
<?php
/**
* Custom Menu Walker - Special Walker classes that manipulate the menus.
*
* WordPress uses a special “Walker” class that iterates over each data record and then displays this
* record accordingly. The cool thing about that is that we can simply create our own custom walker extending
* that PHP class. That way we dont need to care about fetching the stuff from the database or preparing the
* data arrays. We only need to extend the part of the wordpress code that outputs the list.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
<?php
/*
Plugin Name: Profile Builder Custom Page Title on Single User
Plugin URI: http://cozmoslabs.com
Description: Filter wp_title on the Single User Listing
Author: Cristian Antohe
Version: 1.0
Author URI: http://cozmoslabs.com
*/
register_nav_menus( array(
'logged-in' => __( 'Logged-in Menu Area', 'yourtheme' ),
'visitor' => __( 'Visitor Menu Area', 'yourtheme' ),
));
if (is_user_logged_in()){
wp_nav_menu( array(
'menu' => 'Logged In Menu',
'container_class' => 'logged-in-menu',
'theme_location' => 'logged-in'
));
} else {
wp_nav_menu( array(
'menu' => 'Visitor Menu',
'container_class' => 'visitor-menu',