Basic community events user registration question

Home Forums Calendar Products Community Events Basic community events user registration question

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1074081
    clarity
    Participant

    We have purchased and installed Community Events. As a logged in user, the form works well. But if you are not logged in, going to the /community/add page creates a custom page at the same URL with it’s own login form and a link to the standard WordPress registration page. Example:

    http://avindustrycalendar.com/events/community/add/

    We have our own custom login form and registration page. We don’t want the Add an Event page to create its own login form. We want it to go to our form where users can register or log in:

    http://avindustrycalendar.com/login-register/

    I can’t imagine this is not a common question. The standard login form used looks terrible and is not customizable. How can we change that?

    #1074168
    George
    Participant

    Hey @clarity,

    The login from in Community Events is not something generated by Community Events – we use the function built into WordPress itself, wp_login_form().

    You can change the output and build a whole new form on your site, but a simple solution might be to just add this code to your theme’s functions.php file – it will redirect logged-out users on the Community Events submission page to the form you want them to see. Users who are logged-in will not be affected and can access the submission form without issue though:

    add_action( 'tribe_ce_event_submission_login_form', 'redirect_to_better_login_page' );

    function redirect_to_better_login_page() {
    if ( ! is_user_logged_in() ) {
    wp_safe_redirect( 'http://avindustrycalendar.com/login-register/' );
    die();
    }
    }

    #1074534
    clarity
    Participant

    I am confused… this did not do anything. I added this code to the beginning of my functions.php file.

    #1074605
    clarity
    Participant

    Actually, to clarify:

    add_action( ‘tribe_ce_event_submission_login_form’, ‘redirect_to_better_login_page’ );

    This calls a function that doesn’t exist – error

    #1075104
    George
    Participant

    Hey @Clarity,

    That is bizarre! The function is literally defined right there, so that error should not be displaying and this works very well for me.

    Can you copy and paste your ENTIRE, UN-EDITED functions.php file into a Gist at http://gist.github.com and then share a link to this Gist?

    I will take a look and see if I can spot what’s wrong.

    Thanks,
    George

    #1075148
    clarity
    Participant

    Here is the link. All I did was add a few line feeds and insert your code. Breaks the site immediately:

    https://gist.github.com/anonymous/f5555dc2e2e0d11936ba

    Here is the browser error:

    Fatal error: Call to undefined function add_action() in /home/integrat/public_html/avindustrycalendar/wp-includes/functions.php on line 11

    #1078364
    George
    Participant

    Hey Clarity,

    Thanks for this, I see what the issue is—when I said “your theme’s functions.php file”, I perhaps wasn’t being as clear as I could’ve been!

    I am referring to a file within your theme’s folder that is called functions.php. You might be familiar with this file, but if not, then let’s say for example your theme is Twenty Sixteen (I know it’s not, but just for example). Then the file I am referring to would be at this location:

    /wp-content/themes/twenty-sixteen/functions.php

    The “functions.php” file you’ve added the code to presently is in another location in your WordPress installation.

    Remove the code from that functions.php file and try adding it to the file in your theme’s functions.php file.

    Learn more about theme functions files here, if you’re curious → https://codex.wordpress.org/Functions_File_Explained

    Thanks,
    George

    #1078393
    clarity
    Participant

    OK, my bad. I have added it to the functions.php in my theme (its a child theme). Here is the complete contents of that file:

    <?php
     
    add_action( 'tribe_ce_event_submission_login_form', 'redirect_to_better_login_page' );
    
    function redirect_to_better_login_page() {
    	if ( ! is_user_logged_in() ) {
    		wp_safe_redirect( 'http://avindustrycalendar.com/login-register/' );
    		die();
    	}
    }
     
    ?>
    

    It does not work. a non-logged in user is still directed to the same custom page. Ideas?

    • This reply was modified 10 years, 2 months ago by clarity.
    #1080099
    George
    Participant

    Unfortunately there still seems to be an issue with the implementation of that custom code.

    I have tested this numerous times, even now within a child theme, and it works fine, so I’m wondering — it seems like you might be using apostrophes in your custom snippet, which is something that you likely did not do intentionally, but it happened as a result of your copying-and-pasting.

    I would recommend the following exact steps:

    1. Remove all previously-attempted pastes of the code snippet from your theme’s functions.php files.

    2. In your wp-admin, go to Appearance > Editor and navigate to the child theme functions.php file.

    3. Make sure this file is completely empty, and then replace the contents with the content of the complete text at this link: https://git.io/v2YRF

    4. Do not add anything or remove anything. Do not add a closing ?> tag, nothing at all. Just copy the above-shared code in the link in step #3 100% exactly as-is. Change nothing.

    5. Save the changes.

    6. See if things work.

    7. If not, go back to the editor and to the child theme functions.php file.

    8. Change wp_safe_redirect to wp_redirect. Do not change any other characters in the file—all you’re doing here is literally taking “safe_” out of the “wp_safe_redirect” text.

    9. Save the changes. See if things work.

    If things still fail after all of this, then repeat the steps but place the code in your parent theme’s functions.php file and see if that helps.

    Thank you,
    George

    #1080338
    clarity
    Participant

    OK, I have done this again. It STILL redirects to:

    http://avindustrycalendar.com/events/community/add/

    I want it to redirect to:

    http://avindustrycalendar.com/login-register/

    I have done everything as specified in the response. It is not working. I have removed “safe_”, it is not working. I still get this error:

    http://avindustrycalendar.com/events/community/add/

    Warning: Cannot modify header information – headers already sent by (output started at /home/integrat/public_html/avindustrycalendar/wp-content/themes/Divi-child/functions.php:1) in /home/integrat/public_html/avindustrycalendar/wp-includes/pluggable.php on line 1228

    #1080855
    George
    Participant

    This reply is private.

    #1081081
    clarity
    Participant

    George…

    Well, this is embarrassing – for both you and me.

    You gave me these directions a couple messages ago:

    3. Make sure this file is completely empty, and then replace the contents with the content of the complete text at this link: https://git.io/v2YRF

    I did exactly that. Please look at the code you gave me. You did not close the PHP section. I did as suggested an left the PHP open. I should have seen that. I sent you exactly what was in my functions.php file, and you didn’t catch it either.

    I am sorry for missing that. To my defense, I was following directions.

    Thank you for all the help. It now works.

    #1081088
    George
    Participant

    Hey Clarity, the functions.php file does not require a closing PHP tag, and in fact most of the time it can cause issues to add the unnecessary tag there. I’m glad things are resolved now regardless.

    Be sure to bookmark this thread and/or otherwise backup that custom code in case its lost in a theme or site update; that’s unlikely, but just in case!

    Best of luck with your project,
    George

Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘Basic community events user registration question’ is closed to new replies.