Skip to content

Instantly share code, notes, and snippets.

View teolopez's full-sized avatar
🤓

Teodoro Lopez teolopez

🤓
View GitHub Profile
@teolopez
teolopez / additional_contact_fields_wordpress
Last active December 18, 2015 23:28
Additional contact fields in WordPress, display, and saving additional contact field when registering new Wordpress user. Used bootstrap for registration form part. Add this code to your functions.php
// Add Twitter, Facebook and Google+ field to contact methods, remove AIM, YIM and Jabber
add_filter( 'user_contactmethods', 'ts_add_contact_fields' );
function ts_add_contact_fields( $contactmethods ) {
$contactmethods['linkedin'] = 'LinkedIn';
$contactmethods['twitter'] = 'Twitter';
$contactmethods['facebook'] = 'Facebook';
$contactmethods['googleplus'] = 'Google+';
@teolopez
teolopez / WordPress Redirect all non-logged-in users
Last active October 5, 2018 23:52 — forked from daltonrooney/gist:1737771
Redirect all non-logged-in users to the login page (private site). Add to functions.php.
<?php
// ----------------------------------------------------------------------------------------
// Redirect all non-logged-in users to the login page (private site). Add to functions.php.
// ----------------------------------------------------------------------------------------
function admin_redirect() {
if ( !is_user_logged_in()) {
wp_redirect( home_url('/wp-admin/') );
exit;
}
@teolopez
teolopez / WordPress Custom Login Function - functions.php
Last active February 26, 2016 10:43
Custom WordPress Login Form
// ------------------------------------------------------
// custom login style for theme for site url/wp-login.php
// ------------------------------------------------------
function childtheme_custom_login() {
echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('stylesheet_directory') . '/customlogin.css" />';
}
add_action('login_head', 'childtheme_custom_login');
@teolopez
teolopez / WordPress-add new post to user when registering
Created June 30, 2013 05:37
When a new user registers a new post is auto created and assigned to the new user as a draft.
// -----------------------------------------------------------------
// Add Post On New User Registration and Assign to User Registration
// -----------------------------------------------------------------
add_action( 'user_register', 'gamma_new_user_post' );
/**
* Add a new post when user registers.
*/
function gamma_new_user_post( $user_id ) {
@teolopez
teolopez / html5_wp_header.php
Last active December 19, 2015 09:28
html5 boilerplate WordPress header combo
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html <?php language_attributes(); ?> class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><?php wp_title(); ?></title>
@teolopez
teolopez / style.css
Created July 5, 2013 18:20
WordPress Theme Stylesheet General Header
/*
Theme Name: Bear Necessities
Theme URI: http://teolopez.com/themes
Description: Bear Necessities Starter Theme
Author: Teo Lopez
Author URI: http://teolopez.com/
Version: 1.0
Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu (optional)
License: GNU General Public License v2 or later
@teolopez
teolopez / loop-for-custom-post-type
Created July 23, 2013 06:43
victor - use the force i mean this loop =)
<?php
// The Query
$args = array(
'post_type' => 'my_custom_post_type',
'order' => 'DESC', // DESC or ASC
'posts_per_page' => -1,
// Call custom taxonomy
@teolopez
teolopez / customlogin.css
Last active December 20, 2015 06:19
customlogin.css
body.login { background-color: black;}
body.login div#login {}
body.login div#login h1 {margin-bottom: 20px;}
/* ------ UPDATE LOGO IMAGE - NOTE: must declare background size of image ------ */
body.login div#login h1 a {background-position: top center; background-repeat: no-repeat;background-image: url(img/logo.png);height: 109px; background-size: 209px 109px; height: 80px;}
body.login div#login form#loginform { background-color: black; border: none; box-shadow: none;}
body.login div#login form#loginform p {}
body.login div#login form#loginform p label { color: white;}
body.login div#login form#loginform input {}
body.login div#login form#loginform input#user_login {}
@teolopez
teolopez / gist:6085298
Created July 26, 2013 01:24
Custom login form and site lock down
<?php
// ----------------------------------------------------------------------------------------
// Redirect all non-logged-in users to the login page (private site). Add to functions.php.
// ----------------------------------------------------------------------------------------
function admin_redirect() {
if ( !is_user_logged_in()) {
wp_redirect( home_url('/wp-login.php/') );
exit;
@teolopez
teolopez / login_error_message_change
Created July 31, 2013 14:01
change error message for incorrect login credentials.
add_filter( 'login_errors', 'rs_custom_login_error' );
/*
* @desc Filter Wordpress admin error message
*/
function rs_custom_login_error(){
return $error = "Oops!, sorry you have inputted wrong credentials.";
}