Chose a user role at registration

This topic contains 13 replies, has 2 voices, and was last updated by  Atilla Boz 7 years, 1 month ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #368528

    Atilla Boz
    Full Member
    Post count: 280

    Hi guys,

    I need a solution to let users chose what user role they wanna take when they register. Like normal user or advertiser. for now I use the plugin Adding drop down roles in registration which hasnt been updated in years but still works. Bad thing: It only works with the normal WP login form.

    Could you provide a code snippet making it possible to chose user roles with the GD register form, too?

    I found this page, showing how it works with normal WP form:
    http://wordpress.stackexchange.com/questions/195603/how-to-add-users-roles-dropdown-in-registration-in-wordpress

    Thanks in advance,
    Atilla

    #368569

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Atilla,

    Usually we just recommend checking if a user owns a place or not, if not they are not a advertiser, but if you want to go this way you could just divert the registration link to the normal WP registration link?

    Stiofan

    #368702

    Atilla Boz
    Full Member
    Post count: 280

    That is exactly what I did. And on my local instalation it works just perfect, but for some reason om my online test site, the Redirection works only for the login but NOT for the registration. I already tried the snippet Nr 2 from this site but it has no effect so far :/

    https://wpgeodirectory.com/docs/redirecting-the-login-page/

    I opened another thread for that, too and hope we find a solution.

    Atilla

    #368707

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    You would also need snippet no1

    Stiofan

    #368712

    Atilla Boz
    Full Member
    Post count: 280

    I added 1 & 2 now, like this…

    
    
    // Login
    add_filter('geodir_login_url','change_geodir_login_url',10,3);
    	function change_geodir_login_url($login_url,$args,$gd_page_id){
    	//change the url to whatever you want.
    	$login_url = 'http://boz1.timmeserver.de/wp-login.php';
    	return $login_url;
    }
    
    // Registrierung
    add_filter('geodir_login_url','_my_geodir_login_url',10,3);
    	function _my_geodir_login_url($login_url,$args,$gd_page_id){
    	 if(isset($args['signup'])){
    
    	//change the url to whatever you want.
    	 $login_url = 'http://boz1.timmeserver.de/wp-login.php?action=register';
    	 }
    
    	return $login_url;
    }

    but nothing happens / happened.

    #368714

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Please provide wp-admin login and let me know where u added the code and i will take a look.

    Stiofan

    #368716

    Atilla Boz
    Full Member
    Post count: 280
    This reply has been marked as private.
    #368847

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    I added our login widget to the footer and the link all look ok?

    Stiofan

    #368930

    Atilla Boz
    Full Member
    Post count: 280

    I used your code snippets to deactivate the GD login and to redirect it to somewehere else. And that somewhere else is where the WP forms for login and registration are. Login works so far since we get to the link I added in your snippet.

    And when I hover the registration link it also shows the correct link but still redirects me to somewhere else and I dont know why…

    #369052

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Yeah that other redirect is not us, i think that is buddypress?

    Stiofan

    #369240

    Atilla Boz
    Full Member
    Post count: 280

    Yes you`re right Stiofan. I just checked the difference between local and online installation. On the local I did not have Buddypress in use.

    Gotta find out how to stop Buddypress from the redirection I guess…
    Gonna get back with (hopefully good) news.

    Atilla

    #369242

    Atilla Boz
    Full Member
    Post count: 280

    Here we go with the solution. I am still using your code snippets and now, at the same time this here. You have to create a new file called bp-custom.php and add it to /wp-content/plugins/

    And this is how I added the Code:

    
    
    
    <?php
    
    /**
     * Disables BuddyPress' registration process and fallsback to WordPress' one.
     */
    function my_disable_bp_registration() {
      remove_action( 'bp_init',    'bp_core_wpsignup_redirect' );
      remove_action( 'bp_screens', 'bp_core_screen_signup' );
    }
    add_action( 'bp_loaded', 'my_disable_bp_registration' );
    
    add_filter( 'bp_get_signup_page', "firmasite_redirect_bp_signup_page");
        function firmasite_redirect_bp_signup_page($page ){
            return bp_get_root_domain() . '/wp-login.php?action=register'; 
        }
    ?> 

    Had these sources to figure out how it works:
    https://gist.github.com/r-a-y/5578432
    https://buddypress.org/support/topic/use-standard-wordpress-registration/

    Thanks again,
    Atilla

    #369337

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Great, thanks for sharing 🙂

    #369379

    Atilla Boz
    Full Member
    Post count: 280

    But you know what 🙁 Now I tried the first time to register from that form and it gives me a lame ERROR… The plugin was not tested yet for the newest WP version. Gonna get back with news.

Viewing 14 posts - 1 through 14 (of 14 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket