Skip to content

Instantly share code, notes, and snippets.

View gabrielcury's full-sized avatar

Gabriel gabrielcury

View GitHub Profile
@gabrielcury
gabrielcury / 0_reuse_code.js
Created March 24, 2014 14:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@gabrielcury
gabrielcury / wp-new-user-role.php
Created January 17, 2017 00:20 — forked from ewistrand/wp-new-user-role.php
WP Add New User Role Example
<?php
/**
* WP Add New User Role
*/
function wps_add_role() {
add_role( 'manager', 'Manager',
array(
'read' => true,
'edit_posts' => true,
'delete_posts' => true,
@gabrielcury
gabrielcury / gist:dcb76451c2606543b8d86399b262fb7d
Created January 17, 2017 00:20 — forked from projoktibangla/gist:293a03788f37faa4789e
wp user registration without dashboard
<?php
$newuser=wp_create_user('username', 'pass', 'email');
$userrole=new WP_User($newuser);
$userrole -> ser_role('administrator');
//or
$userrole=new WP_User(wp_create_user('username', 'pass', 'email'));
$userrole -> ser_role('administrator');
?>
@gabrielcury
gabrielcury / automagic-login.php
Created January 17, 2017 00:20 — forked from digisavvy/automagic-login.php
Programmatically Login a WP User
/**
* Programmatically logs a user in
*
* @param string $username
* @return bool True if the login was successful; false if it wasn't
*/
function programmatic_login( $username ) {
if ( is_user_logged_in() ) {
wp_logout();
}
@gabrielcury
gabrielcury / add-user.php
Created January 17, 2017 00:20 — forked from rqreyes/add-user.php
create a WP admin user
<?php
// Create Admin User
$wp_password = 'PASSWORD'; #enter your desired password here, if you don't line 16 makes sure nothing bad happens like setting you actual password to 'PASSWORD'
$wp_username = 'USERNAME';
$wp_email = 'EMAIL';
if ( $wp_password === 'PASSWORD' )
die;
@gabrielcury
gabrielcury / create_user.php
Created January 17, 2017 00:22 — forked from yanknudtskov/create_user.php
Create WP User
public function custom_create_user($user_name, $first_name, $last_name, $email_address, $user_role = 'subscriber')
{
$user_id = username_exists( $user_name );
if( $user_id != null )
{
throw New Exception('Username already exists!');
}
if ( email_exists($email_address) == true )
@gabrielcury
gabrielcury / gist:6d9dd6af0832ebdbcfff8ac9fc375fe3
Created September 13, 2019 18:51 — forked from Mikodes/gist:be9b9ce42e46c3d4ccb6
All Media queries for resolutions
/* (320x480) iPhone (Original, 3G, 3GS) */
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
/* insert styles here */
}
/* (320x480) Smartphone, Portrait */
@media only screen and (device-width: 320px) and (orientation: portrait) {
/* insert styles here */
}