• Resolved elrico13

    (@elrico13)


    If someone volunteering for an opportunity is already logged into our WordPress site, can we avoid prompting them for an email address?

    If a logged-in user enters a different email address to the one they joined our site with, it creates an unwanted account in our database.

    It would be great to stop this happening.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jonathan Goldford

    (@jg-visual)

    Thanks for reaching out @elrico13. This is possible, but there are a few reasons why it might be worth keeping the email field.

    1. In a lot of cases users want to not only sign themselves up, but want to sign up others as well. For example, a man might sign up, then sign up his wife and two children as well.
    2. In some cases individuals prefer to use different email addresses for different purposes. Like you mentioned, it does create another user for each email address, but depending on how your site is set up, it hopefully won’t cause any issues given they will have the “Volunteer” role.

    All that said, if those don’t apply to you, you can automatically populate and hide the email field by working within the plugin’s templating system. You would need a good understanding of coding to do this. Are you comfortable with PHP coding or do you have a web developer who might be able to help you?

    Have a good one.

    Jonathan

    Thread Starter elrico13

    (@elrico13)

    Thanks for the reply Jonathan. It’s good to know it’s possible. For our usage, we never want someone to enter a different email address as only our members are allowed to volunteer for these tasks.

    I’ve done some light PHP coding – customising other people’s code rather than writing from scratch. Do you have any sample code for this? If not I’ll try and work it out and post the results here if it flies.

    Plugin Author Wired Impact

    (@wiredimpact)

    Unfortunately, we don’t have any sample code to provide, but I can write out some steps that might be helpful for you:

    1. Find the plugin file located at wp-content/plugins/wired-impact-volunteer-management/templates/opp-single-form.php
    2. Copy that file into your current theme in a new folder called “wivm”
    3. Within that file find the the label with the “for” attribute of “wivm_email”. This label and the input immediately after it are the ones you want to modify
    4. You’ll most likely want to change the field type from “email” to “hidden”, then adjust the “value” attribute to automatically populate the correct email address. To do this I’d recommend taking a look at is_user_logged_in() and wp_get_current_user().

    I hope that’s a good start. If you’d like us to give you a bid to help you all with it let me know, but hopefully you can get it working on your end. Good luck.

    Jonathan

    Thread Starter elrico13

    (@elrico13)

    Thanks Jonathan – that looks very helpful!

    I probably won’t have a chance to get this working for a few days, but if I crack it I will post the results here in case it is of use to anyone else.

    Plugin Author Wired Impact

    (@wiredimpact)

    That sounds good to me. I’ll leave this ticket open for a little while in case you have any other questions. Good luck!

    Jonathan

    Thread Starter elrico13

    (@elrico13)

    Jonathan

    I’ve got it working – thanks for all your help!

    One thing I’m wondering, will the wivm subfolder survive a theme update? Or should I be putting it into a child theme?

    Here’s what I did in case anyone else finds it useful.

    I created a copy of opp-single-form.php in a wivm subfolder in the current theme, and replaced the existing email <input> with the following:

    <input readonly type="email" tabindex="930" id="wivm_email" name="wivm_email" value="<?php $current_user = wp_get_current_user(); echo $current_user->user_email; ?>" />

    I tested with type="hidden" first, and with logged-in users it worked perfectly.

    However when testing with non-logged-in users, despite the returned email address obviously being blank, somehow submitting the form assigned the site Admin to the opportunity and lost the other details.

    Using readonly avoids this as the form validation prevents the form being submitted if the email is blank.

    Plugin Author Wired Impact

    (@wiredimpact)

    Excellent point about theme updates. Yes, if you’re using a theme that receives updates, such as those from www.remarpro.com or a paid theme, it’s probably best if you use a child theme. That said, you can always make a backup before any updates, then copy the wivm folder back within the theme after you update.

    I’m happy to hear you were able to make your site automatically populate the email addresses. And I’m glad we were able to provide some direction.

    I’ll go ahead and mark this as resolved, but let me know if you have any other questions.

    Jonathan

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Remove email prompt for logged-in users’ is closed to new replies.