Title: Perform Logout function
Last modified: May 30, 2019

---

# Perform Logout function

 *  Resolved [aangel8](https://wordpress.org/support/users/aangel8/)
 * (@aangel8)
 * [7 years ago](https://wordpress.org/support/topic/perform-logout-function/)
 * is there a way to perform the logout progmatically? I’m trying to create a button
   that logs the user out and redirects to a custom URL but I do not want the user
   to redirect every time they logout, ONLY when they click this custom button.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Rogier Lankhorst](https://wordpress.org/support/users/rogierlankhorst/)
 * (@rogierlankhorst)
 * [7 years ago](https://wordpress.org/support/topic/perform-logout-function/#post-11589430)
 * This is more a core Ultimate Member question, but I think what you want is possible
   with one of the filters Ultimate Member provides. This filter returns the URL
   the user is redirected to after logging out. The result would look something 
   like this:
 *     ```
       add_filter( 'um_logout_redirect_url', 'umnm_redirect_logout', 10, 2 );
       function umnm_redirect_logout($url, $user_id){
           if (isset($_POST['custom_logout_button'])){
               return 'https://my_custom_redirect_url.com';
           }
           return $url;
       }
       ```
   
 *  Thread Starter [aangel8](https://wordpress.org/support/users/aangel8/)
 * (@aangel8)
 * [7 years ago](https://wordpress.org/support/topic/perform-logout-function/#post-11592928)
 * excuse my lack of knowledge in coding but is this added in the functions.php 
   file or is this html that can be placed into an object?
 *  Plugin Author [Rogier Lankhorst](https://wordpress.org/support/users/rogierlankhorst/)
 * (@rogierlankhorst)
 * [7 years ago](https://wordpress.org/support/topic/perform-logout-function/#post-11593985)
 * This can be placed in your functions.php.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Perform Logout function’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/um-new-members-widget.svg)
 * [UM New Members](https://wordpress.org/plugins/um-new-members-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/um-new-members-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/um-new-members-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/um-new-members-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/um-new-members-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/um-new-members-widget/reviews/)

## Tags

 * [Logout](https://wordpress.org/support/topic-tag/logout/)

 * 3 replies
 * 2 participants
 * Last reply from: [Rogier Lankhorst](https://wordpress.org/support/users/rogierlankhorst/)
 * Last activity: [7 years ago](https://wordpress.org/support/topic/perform-logout-function/#post-11593985)
 * Status: resolved