Skip to content

Instantly share code, notes, and snippets.

View raphaelnikson's full-sized avatar

Raphael Nikson raphaelnikson

View GitHub Profile
<?php if (isset($_POST['action']) == "wp_inserir_usuario"): ?>
<?php if (wp_verify_nonce($_POST['inserir_usuario_field'],'inserir_usuario_action')): ?>
<?php
$userdata = array(
'nickname' => $_POST['user_name'],
'user_login' => $_POST['user_name'],
'user_email' => $_POST['user_mail'],
'user_pass' => $_POST['user_pass'],
'role' => $_POST['user_role'],
@raphaelnikson
raphaelnikson / gravity-forms-notification-popup.css
Created December 2, 2016 08:53 — forked from anythinggraphic/gravity-forms-notification-popup-keep-form.php
Gravity Forms Notification Popup (Genesis Framework)
#overlay {
background: #000;
background: rgba(0, 0, 0, 0.3);
display: block;
float: left;
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
@raphaelnikson
raphaelnikson / dropzonejs-wp-rest-api.js
Created July 20, 2016 01:20 — forked from soderlind/dropzonejs-wp-rest-api.js
DropzoneJS & WordPress REST API
/*
Uploading images is a two step process (from https://github.com/WP-API/WP-API/issues/1768#issuecomment-160540932):
POST the data to /wp/v2/media - this can either be as the request body, or in multipart format. This will upload the file, and give you a 201 Created response with a Location header. This header points to the post object for the attachment that has just been created.
PUT the post data to the endpoint returned in the Location header (which will look something like /wp/v2/media/{id}).
I do step 2 (PUT), if POST is a success, in myDropzone.on("success", function(file, response){}
*/
// dropzoneWordpressRestApiForm is the configuration for the element that has an id attribute
@raphaelnikson
raphaelnikson / CreateWordpressUser.php
Created July 19, 2016 15:33 — forked from jawinn/CreateWordpressUser.php
Create WordPress Admin User from PHP
<?php
// ADD NEW ADMIN USER TO WORDPRESS
// ----------------------------------
// Put this file in your Wordpress root directory and run it from your browser.
// Delete it when you're done.
require_once('wp-blog-header.php');
require_once('wp-includes/registration.php');
// ----------------------------------------------------
@raphaelnikson
raphaelnikson / WordPress Registration
Created July 19, 2016 15:32 — forked from menslow/WordPress Registration
WordPress: Simple registration function for custom front-end registration forms.
/**
* mm_register function.
* Register a new user.
* @access public
* @return User errors or user is logged in.
*/
function mm_register() {
if(!is_user_logged_in()) {
if(!empty($_POST)) {
@raphaelnikson
raphaelnikson / wp-db.tutorial.php
Created July 14, 2016 15:55 — forked from benbalter/wp-db.tutorial.php
WordPress DB Tutorial
<?php
//absolute path to wp-load.php, or relative to this script
//e.g., ../wp-core/wp-load.php
include( 'trunk/wp-load.php' );
//grab the WPDB database object, using WP's database
//more info: http://codex.wordpress.org/Class_Reference/wpdb
global $wpdb;
@raphaelnikson
raphaelnikson / Frontend user profile in WordPress
Created July 3, 2016 14:11 — forked from chrisdigital/Frontend user profile in WordPress
Setting up a editable user profile in WordPress on the frontend.
//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
@raphaelnikson
raphaelnikson / file-upload-handler.php
Created June 21, 2016 01:12 — forked from daltonrooney/file-upload-handler.php
Multi-file WordPress uploads from the front-end
<?php /* This function attaches the image to the post in the database, add it to functions.php */
function insert_attachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
@raphaelnikson
raphaelnikson / gist:f8d4890fe39559bd00a63d5b3fa4b908
Created May 12, 2016 00:02 — forked from rutger1140/gist:4994751
Gravity Forms hook - disable auto scrolling to anchor after submit
// Gravity Forms anchor - disable auto scrolling of forms
add_filter("gform_confirmation_anchor", create_function("","return false;"));
@raphaelnikson
raphaelnikson / youtube-api-curl.php
Created April 13, 2016 00:16 — forked from bstaruk/youtube-api-curl.php
This is a snippet of code that will display all videos found within a playlist, utilizing the YouTube API via cURL.
<?php
$playlistID = 'YOUR_PLAYLIST_ID_GOES_HERE'; //Playlist ID, do not include "PL" that is usually in the beginning of a Playlist ID
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://gdata.youtube.com/feeds/api/playlists/' . $playlistID . '?v=2&alt=json');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$output = curl_exec($ch);