Tag Archives: plugin

Blog, Ultimate Member

Ultimate Member keep me signed in option not possible to disable

If you use Ultimate Member, you might have come across the issue that it’s not possible to disable the “keep me signed in” checkbox, when on the login page. This is caused by the validation javascript in Ultimate Member, located in um-conditional.js. From each um-field class element, the data attribute “key” is retrieved. But this…

Continue reading

Easy Digital Downloads

Retrieving the license status for a key in Easy Digital Downloads

As a user of Easy Digital Downloads software licensing, I was looking for a way to retrieve the Easy Digital Downloads license status. I use this to determine the license status on submit of the support form of the EDD websites. Though I might have missed something, there doesn’t seem to be a direct way…

Continue reading

Blog, Easy Digital Downloads, Moneybird

Easy Digital Downloads MoneyBord 1.0.7

In the latest release of Easy Digital Downloads MoneyBird, EDD MoneyBird in short, we have added several cool new features: Support for periods in MoneyBird If you use EDD recurring, the synchonised invoices will now have the corresponding periods added. Support for the EDD VAT EU: VAT number and VAT company will be synchronised as…

Continue reading


Sending a password reset link for PHP added WordPress users

Sometimes you need to create users in WordPress with PHP code, be it because you’re importing users, or because you want to let one user add other users. When you do this you want the new users to be able to reset their password.

At first I thougth to use a password reset link, to the password reset page in WordPress, but this is not very user friendly:

  1. The user has to enter his username or email address
  2. The user will receive a resetmail with a link.
  3. After clicking it, the user can reset the password.

It would be much better if we could directly send the resetlink that leads to the third step. To do this we need to create a password reset key, which is only temporarily valid.

The code below generates such an email.

function dtc_send_password_reset_mail($user_id){

    $user = get_user_by('id', $user_id);
    $firstname = $user->first_name;
    $email = $user->user_email;
    $adt_rp_key = get_password_reset_key( $user );
    $user_login = $user->user_login;
    $rp_link = '<a href="' . wp_login_url()."/resetpass/?key=$adt_rp_key&login=" . rawurlencode($user_login) . '">' . wp_login_url()."/resetpass/?key=$adt_rp_key&login=" . rawurlencode($user_login) . '</a>';

    if ($firstname == "") $firstname = "gebruiker";
    $message = "Hi ".$firstname.",<br>";
    $message .= "An account has been created on ".get_bloginfo( 'name' )." for email address ".$email."<br>";
    $message .= "Click here to set the password for your account: <br>";
    $message .= $rp_link.'<br>';

    //deze functie moet je zelf nog toevoegen. 
   $subject = __("Your account on ".get_bloginfo( 'name'));
   $headers = array();

   add_filter( 'wp_mail_content_type', function( $content_type ) {return 'text/html';});
   $headers[] = 'From: Your company name <info@your-domain.com>'."\r\n";
   wp_mail( $email, $subject, $message, $headers) === false);

   // Reset content-type to avoid conflicts -- http://core.trac.wordpress.org/ticket/23578
   remove_filter( 'wp_mail_content_type', 'set_html_content_type' );

Exclude pages from caching based on post type

To improve site speed for a website I often use WP Rocket: I think it’s one of the fastest caching plugins for WordPress. When a page is being cached, it’s actually saved in a separate folder as a html file. This way, the website doesn’t have to create the page from the php code: there’s a ready made file that can be served immediately. This is way faster then when the server needs to parse the entire code (of course this depends on your server speed as well).

In some cases it is not convenient to cache every page straight from the cache. For example, if you have a webshop with a sidebar with cart, where sometimes a product is in the cart, but sometimes it isn’t. You don’t want the product to be always in the cart, even if the user didn’t add it yet… This is what I encountered with an Easy Digital Downloads webshop.

Of course you can disable caching for those pages. That’s what I did first: I added the DONOTCACHE constant to the downloads template. But when you do that, you also lose the other features of WP Rocket, like the javascript minification etc. As a result, users who have visited the homepage first, have the minified js files in the cache, so the browser will then download the unminified js files. This is not optimal. I wanted to keep those features, without the page being cached.

To achieve this I’ve contact WP Rocket support, who were very helpful. In the end we created a solution where the page cache is not used for the post type ‘download’. In WooCommerce you could use post type ‘product’ to achieve the same thing.


  don't create page cache on downloads pages. 


add_action('wp', 'rsssl_wprocket_no_page_cache');

function rsssl_wprocket_no_page_cache(){
  global $post;

  if ($post && ( get_post_type($post)=='download' ) ) {



Ultimate Member

Automatically send private messages in Ultimate Member

For a project where messages had to be sent automatically to the users without additional email being sent, I’ve chosen to use private messages for this purpose.

In this project when a user uploads a new file, a private message should be sent to another user. This way there is not a flood of annoying emails. Ultimate Member will send an email if the receiving user does not log in to check his private messages. This email will normally be sent once a day.

In the code where the update is received, I add this function:

rsp_send_private_message($to, $from, $message);

  * Send a private message from a user to a user 
  * @since   
  * @param  int $to   User id the message is directed to
  * @param  int $from User id the message should come from
  * @param  string $message The text message
  * @return bool             void 
function rsp_send_private_message($to, $from, $message){
  global $ultimatemember, $um_messaging;
  // Create conversation and add message
  $_POST['content']  = "Automatically generated message: " . $message;
  $conversation_id = $um_messaging->api->create_conversation( $to, $from );
  //$output['messages'] = $um_messaging->api->get_conversation($to, $from, $conversation_id );
  $_POST['content'] = "";
  do_action('um_after_new_message', $to, $from, $conversation_id );