mayo 2020

Custom logout

/** Custom Logout Shortcode
 */
 function custom_logout_link_func() {
            $return = wp_logout_url();?>
            <a href="<?php echo $return; ?>" class="btn btn-primary btn-xs btn-block" role="button" style="margin-bottom: 10px;">Logout</a>
            <?php
        }
         
    add_shortcode('logout_link', 'custom_logout_link_func');
/**
 *Used to redirect after logout 
 */
 
function logout_page() {
    $login_page  = home_url();
    wp_redirect( $login_page . "" );
    exit;
}
add_action('wp_logout','logout_page');

https://toolset.com/forums/topic/create-a-logout-link/

Custom logout Leer más »

WP-Cred login form: redirects based on different member roles

/**
 * Redirect user after successful login.
 *
 * @param string $redirect_to URL to redirect to.
 * @param string $request URL the user is coming from.
 * @param object $user Logged user's data.
 * @return string
 */
function my_login_redirect( $redirect_to, $request, $user ) {
    //is there a user to check?
    if ( isset( $user->roles ) && is_array( $user->roles ) ) {
        //check for admins
        if ( in_array( 'administrator', $user->roles ) ) {
            // redirect them to the default place
            return $redirect_to;
        } else {
            return home_url();
        }
    } else {
        return $redirect_to;
    }
}
 
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );

https://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect

function my_login_redirect( $redirect_to, $request, $user ) {
    if( !isset( $user->user_login ) ){ // we only want this to run when credentials have been supplied
        return $redirect_to;
    }
    //is there a user to check?
    if (isset($user->roles) && is_array($user->roles)) {
        //check for subscribers
        if (in_array('subscriber', $user->roles)) {
            // redirect them to another URL, in this case, the homepage
            $redirect_to =  '<em><u>hidden link</u></em>';
        }
 
        if (in_array('contributor', $user->roles)) {
            // redirect them to another URL, in this case, the search page
            $redirect_to = '<em><u>hidden link</u></em>';
        }
 
        // copy and paste the block above for each role
    }
 
    return $redirect_to;
}
 
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );

https://toolset.com/forums/topic/need-to-have-1-login-form-that-redirects-based-on-wp_user-role/

WP-Cred login form: redirects based on different member roles Leer más »

Change “Return to Shop” Button Link – WooCommerce

/**
 * @snippet       Change return to shop link, send to homepage instead
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=603
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.5.6
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
 
add_filter( 'woocommerce_return_to_shop_redirect', 'bbloomer_change_return_shop_url' );
 
function bbloomer_change_return_shop_url() {
	return home_url();
}

Visto en https://businessbloomer.com/woocommerce-change-return-shop-url/

Change “Return to Shop” Button Link – WooCommerce Leer más »

Primera letra de cada custom post type

[wpv-layout-start]
    [wpv-items-found]
    <a href="[current_url]">All</a>
    <!-- wpv-loop-start -->
        <wpv-loop>
            <a href="?wpvalphabet=[wpv-taxonomy-title]">[wpv-taxonomy-title]</a>
        </wpv-loop>
    <!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-no-items-found]
        <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
    [/wpv-no-items-found]
[wpv-layout-end]
add_shortcode( 'current_url', function(){
    
    $request = $_SERVER['HTTP_HOST'].strtok($_SERVER["REQUEST_URI"],'?');
    $protocol = 'http://';
    
    if ( isset($_SERVER['HTTPS']) ) {
        $protocol = 'https://';
    }
    
    return $protocol . $request;
} );
wpv-layout-start]
[wpv-view name="alphabet-terms"]
[wpv-items-found]
<!-- wpv-loop-start -->
        <wpv-loop>
            <h3>[wpv-post-link]</h3>
        </wpv-loop>
    <!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-no-items-found]
        <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
    [/wpv-no-items-found]
[wpv-layout-end]
add_filter('wpv_filter_query', 'func_filter_by_title', 10, 2);
function func_filter_by_title($query, $setting) {
  
global $wpdb;
      
if($setting['view_id'] == 9999) {
          
        if(isset($_GET['wpvalphabet']) and $_GET['wpvalphabet']!='' ){
              
              
            $first_char = $_GET['wpvalphabet'];
            $postids = $wpdb->get_col($wpdb->prepare("SELECT      ID
                                                        FROM        $wpdb->posts
                                                        WHERE       SUBSTR($wpdb->posts.post_title,1,1) = %s
                                                        AND post_type = '".$query['post_type'][0]."'
                                                        AND post_status = 'publish'
                                                        ORDER BY    $wpdb->posts.post_title",$first_char)); 
                                                          
                  $query['post__in'] = $postids;
                  }
  }
return 

https://toolset.com/forums/topic/show-hidden-links/#post-1612419

Primera letra de cada custom post type Leer más »

Scroll al inicio