Skip to content

Instantly share code, notes, and snippets.

@BryanBarrera
BryanBarrera / Wordpress Data Layer Variables
Last active May 8, 2020 08:35 — forked from chipoglesby/Wordpress Data Layer Variables
Modified Wordpress datalayer variables for pulling: author names, post types, categories, page name, and dates into custom variables for the classic version of Google Analytics. Feel free to leave a comment or hit me up http://BryanBarrera.com
// Add this script after you make your dataLayer = []; call
// AND after your GTM code snippet
// This needs to go inside the header.php in order for it work globally across your site
<script type="text/javascript">
// URL toolbox - helps grabbing elements in the URL
var _d = document;
var _dl = _d.location;
var _dlp = _dl.pathname;
var _dls = _dl.search;
var _dr = _d.referrer;
<form class="mc-form-example" method="POST" action="./endpoint.php">
<h3>Newsletter Sign Up</h3>
<label for="mc-email">Email Address:</label>
<input type="email" id="mc-email" name="mc-email" required/>
<input type="text" value="pending" id="status" name="status" hidden/>
<input type="submit" value="Submit">
</form>
<?php
// Allow subscribers to see Private posts and pages
$subRole = get_role( 'subscriber' );
$subRole->add_cap( 'read_private_posts' );
$subRole->add_cap( 'read_private_pages' );
// Redirect to home page on login
function loginRedirect( $redirect_to, $request_redirect_to, $user ) {
if ( is_a( $user, 'WP_User' ) && $user->has_cap( 'edit_posts' ) === false ) {
@sente
sente / reddit.html
Created April 28, 2011 22:32
An example of a retrieving data from reddit's JSON(p) api using jquery
<!DOCTYPE html>
<!--
Stuart Powers
http://sente.cc/
http://twitter.com/stuartpowers
-->
<html>
<head>