Skip to content

Instantly share code, notes, and snippets.

View gist:07d5500a0c56cd57984d4d0551138ce5
function mailster_custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'mailster_excerpt_length', 'mailster_custom_excerpt_length', 999 );
@evrpress
evrpress / lastname
Last active Feb 27, 2017
Populates the last name if present in the first name field
View lastname
add_filter( 'mailster_verify_subscriber', function( $entry ) {
if ( isset( $entry['firstname'] ) ) {
$names = explode( ' ', $entry['firstname'] );
$entry['firstname'] = array_shift( $names );
if ( ! empty( $names ) ) {
$entry['lastname'] = implode( ' ', $names );
}
}
View gist:ecb2f56d10f08ead549d2e3a7b20cad7
function mailster_lists_only_unsubscribe($subscriber_id, $campaign_id){
//unsubscribe user if campaign doesn't exists or isn't set
if(!mailster('campaigns')->get($campaign_id)) return;
$subscriber = mailster('subscribers')->get($subscriber_id);
if($subscriber){
//change back to subscribed (silently)
mailster('subscribers')->change_status($subscriber_id, 1, true);
//get lists from the campaign
@evrpress
evrpress / send_first_pregnancy_campaing
Last active Mar 21, 2017
Sends the first campaign of a drip campaign
View send_first_pregnancy_campaing
add_action( 'mailster_subscriber_subscribed', 'send_first_pregnancy_campaing' );
function send_first_pregnancy_campaing( $subscriber_id ) {
//get subscriber
if ( $subscriber = mailster( 'subscribers' )->get( $subscriber_id ) ) {
$seachstring = "Pregnancy week %d";
$total_weeks = 40;
//no birthdate
View hook into mailster_verify_subscriber
add_filter( 'mailster_verify_subscriber', 'my_mailster_verify_subscriber' );
function my_mailster_verify_subscriber( $entry ) {
//verify subscriber with custom methods
return $entry;
}
@evrpress
evrpress / gist:0233566f5ec2a14f9db743c8bb271870
Last active Feb 27, 2017
Change the HTML of MyMail Forms
View gist:0233566f5ec2a14f9db743c8bb271870
add_filter( 'mailster_form', 'change_mailster_form_html', 10 , 3 );
function change_mailster_form_html( $html, $form_id, $form ) {
//do some replacements
return $html;
}
@evrpress
evrpress / Add user to list after click on link
Last active Feb 27, 2017
Assigns a subscriber to a certain list if a certain link has been clicked
View Add user to list after click on link
@evrpress
evrpress / add_class_if_subscriber
Last active Feb 27, 2017
add body class if current user is subscriber
View add_class_if_subscriber
add_filter( 'body_class', 'add_class_if_subscriber' );
function add_class_if_subscriber( $classes ) {
$user_ID = get_current_user_id();
$subscriber = mailster('subscribers')->get_by_wpid($user_ID);
if($subscriber){
$classes[] = 'is-mailster-subscriber';
}
return $classes;
}
@evrpress
evrpress / append_date_to_auto_tag
Last active Feb 27, 2017
append_date_to_auto_tag
View append_date_to_auto_tag
function append_date_to_auto_tag($pattern, $post_type, $options, $post){
$pattern['content'] .= "<br>".'{'.$post_type.'_date:'.$options.'}';
return $pattern;
}
add_filter('mailster_auto_tag', 'append_date_to_auto_tag', 10, 4);
@evrpress
evrpress / remove_bmi_links
Last active Feb 27, 2017
BMI Wrong Image Link Fix
View remove_bmi_links