Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
andrewlimaza / honeypot-example.php
Last active October 5, 2023 04:20
Simple honeypot for an HTML form using PHP
<?php
//check if form was sent
if($_POST){
$to = 'some@email.com';
$subject = 'Testing HoneyPot';
$header = "From: $name <$name>";
$name = $_POST['name'];
@gabrielmerovingi
gabrielmerovingi / mycred-take-shortcode
Last active October 21, 2022 22:19
Use this custom WordPress shortcode to deduct points from your users when they press a button.
/**
* Shortcode: Take Points
* This custom shortcode allows you to take points from your users when they
* click on the button this shortcode generates. Supports optional confirmation message.
* @version 1.0.2
*/
add_shortcode( 'mycred_take', 'mycred_pro_render_take_shortcode' );
function mycred_pro_render_take_shortcode( $atts, $label = 'Give Away' ) {
extract( shortcode_atts( array(
@kevinwhoffman
kevinwhoffman / loop-custom.php
Last active April 8, 2022 11:22
WordPress - Custom Post Type Loop
<?php
$loop = new WP_Query( array(
'post_type' => 'Property',
'posts_per_page' => -1
)
);
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
@gabrielmerovingi
gabrielmerovingi / myCRED Front End Editor
Created March 28, 2014 23:18
Example of a simple adjustment form for myCRED that can be used from the front.
add_shortcode( 'mycred_manual_adjustments', 'mycred_render_manual_adjustments' );
function mycred_render_manual_adjustments( $atts, $content = NULL ) {
// Must be logged in
if ( ! is_user_logged_in() ) return;
// myCRED must be enabled
if ( ! function_exists( 'mycred' ) ) return 'myCRED is not installed';
// Load myCRED
$mycred = mycred();
@johnpbloch
johnpbloch / protected-roles.php
Created March 13, 2012 14:07
Define 'protected' WordPress roles that can only be deleted by users of at least one protected role. This allows you to enable clients to create, edit, and delete users without deleting your account.
<?php
class JPB_User_Caps {
/**
* An array of all protected roles
* @var array
*/
protected $protectedRoles = array(
'webmaster',