Asked  8 Months ago    Answers:  5   Viewed   53 times

I have a website, with a user system. I want to integrate wordpress's user system into that website's, but I still want to use the website's register/login pages. I don't want anybody to be able to login or register using Wordpress's login or registration forms. Instead, when they're try to access the login/registration pages in Wordpress, I want those pages to redirect them to my own login/registration pages.

Is there any way of doing this? I've tried Google, but all I could find was redirection AFTER the user logs in or registers, which is not what I want.

Thank you in advance.

 Answers

67

For this you need to redirect login/registration page to your custom pages. So, Write this code in your functions.php file Under your activated theme folder. Pass your custom page path as a Argument.

 add_action('init','possibly_redirect');

function possibly_redirect(){
 global $pagenow;
 if( 'wp-login.php' == $pagenow ) {
  wp_redirect('http://google.com/');
  exit();
 }
}
Wednesday, March 31, 2021
 
Dev
answered 8 Months ago
Dev
98

This should solve your problem. Adapted from an answer found here.

Add the following snippet of code in the functions.php file of your theme:

function admin_default_page() {
  return '/new-dashboard-url';
}

add_filter('login_redirect', 'admin_default_page');
Wednesday, March 31, 2021
 
employeegts
answered 8 Months ago
66

I don't think it supports Twig templates but for sure you can write your custom Template class to render the pagination however you want.

Let's say in your AppBundle, you will need to create MyCustomTemplate class which should extend PagerfantaViewTemplateDefaultTemplate:

<?php

namespace AcmeAppBundleTemplate;

use PagerfantaViewTemplateDefaultTemplate;

class MyCustomTemplate extends DefaultTemplate
{
    // override whatever you need here ...
}

then register it in your services.yml file together with the view service:

services:
    acme_app.template.my_template:
        class: AcmeAppBundleTemplateMyCustomTemplate

    pagerfanta.view.my_template:
        class: PagerfantaViewDefaultView
        public: false
        arguments:
            - "@acme_app.template.my_template"
        tags: [{ name: pagerfanta.view, alias: my_template }]

then in your Twig templates you will be able to use:

{{ pagerfanta(my_pager, 'my_template') }}

which will result in displaying your custom pagination template.

Wednesday, March 31, 2021
 
aurelijusv
answered 8 Months ago
86

Im not sure didnt test but you can use user roles with if else statement

function redirect_after_logout() {
    if (!current_user_can('manage_options')) { 
        $url = '/';
    } else { 
        $url = 'member-login?logged_out=true';
    }
    $redirect_url = home_url( $url );
    wp_safe_redirect( $redirect_url );
    exit;
}
add_action( 'wp_logout', array( $this, 'redirect_after_logout' ) );
Saturday, May 29, 2021
 
hillz
answered 5 Months ago
13

you using getUrl and getBaseUrl and it's the same thing, you can use this code:

$this->_redirect('module/controller/action','parameters');

but u have extends Mage_Adminhtml_Controller_Action on your class. its the best way. if isn't a controller so u shouldn't do this redirect.

Saturday, May 29, 2021
 
SheppardDigital
answered 5 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share