Tag Archives: ultimate member

Ultimate Member

How to install your Ultimate Member add-on

Installing and activating your Ultimate Member add-on can be done in a number of simple steps. Installing the plugin and activating the license can be done as follows: download the zipped plugin via the link in the purchase receipt e-mail. Alternatively, log-in to your account page and download the zip file from there. Go to…

Continue reading

Ultimate Member

Ultimate Member 2.0 compatibility

Ultimate Member 2.0 is coming, and there are breaking changes. We have now tested all our plugins with UM2.0, and made additions where necessary. In most cases the changes are limited to the way the settings are handled. If you have upgraded Ultimate Member you will notice the settings pages have changed. As a developer,…

Continue reading

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

Blog, Ultimate Member

Search users on username, email address, firstname and lastname

If you want to do a search in your WordPress users, or in Ultimate Member members, (which amounts to the same thing), you would think this can be easily done with a meta_query, or with the search query functionality that is built in into WordPress.

This is not the case! When creating some code doing this, I discovered that with a meta_query, a user searched by username doesn’t get found. Looking in the query that is created by WordPress, I noticed that WordPress only searches in the wp_user_meta table. The username is part of the wp_users table.

On the other hand, if you use the “search” query, WordPress only searches in the users table, so won’t find users by firstname or lastname.

To solve it, you have to combine the two. In the example below, the totalusers variable contains the list of users that matches the input $str on either username, user_nicename, user_email, firstname, or lastname. You can extend it at will of course.

//search usertable
$wp_user_query = new WP_User_Query(
  array(
    'search' => "*{$str}*",
    'search_columns' => array(
    'user_login',
    'user_nicename',
    'user_email',
  ),

) );
 $users = $wp_user_query->get_results();

//search usermeta
 $wp_user_query2 = new WP_User_Query(
  array(
    'meta_query' => array(
    'relation' => 'OR',
      array(
        'key' => 'first_name',
        'value' => $str,
        'compare' => 'LIKE'
      ),
    array(
        'key' => 'last_name',
        'value' => $str,
        'compare' => 'LIKE'
      )
    )
  )
 );

$users2 = $wp_user_query2->get_results();

$totalusers_dup = array_merge($users,$users2);

$totalusers = array_unique($totalusers_dup, SORT_REGULAR);
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){
  //We do not want to message ourselves
  if ($from==$to) return;
  // Create conversation and add message
  $_POST['content']  = "Automatically generated message: " . $message;
  $conversation_id = UM()->Messaging_API()->api()->create_conversation( $to, $from );;
  $_POST['content'] = "";
  do_action('um_after_new_message', $to, $from, $conversation_id );
}
×