How can I remove the Eventbrite API key field from registraion/profile form?

Home Forums Ticket Products Eventbrite Tickets How can I remove the Eventbrite API key field from registraion/profile form?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #32091
    Alek
    Participant

    After adding the Eventbrite tickets add-on, an “Eventbrite User Account” section is appearing on my registration/profile pages. This askes users for their API key. Why would it ask each user for this? There should be just one for the whole site, yes? In any case, I need to remove this so it doesn’t show up. I am using Cimy Extra User Fields, and Theme My Login to create front-end registration/login/profile pages and cannot have this fields showing up for all users. It’s not at all applicable to all but Admins, and even then makes no sense that it would be shows separately for each user. How can I remove this section/field from showing up on these forms?

    #32099
    Barry
    Member

    You could try adding this to your theme’s functions.php file: that means the fields will still be visible to those users you designate but not to others.

    Do note however that I have not tested this using the plugins you mentioned, only on a default installation.

    Why would it ask each user for this? There should be just one for the whole site, yes?

    It allows for scenarios where different admins can work with and pull events in from different Eventbrite accounts that they might be managing. The alternative for sites that need to work with multiple Eventbrite accounts would be to make the keys universal and have the admin select which key he or she wants to work with on every single operation.

    It’s not perfect and may be revised in the future – but I understand that to be the basic reasoning.

    #32167
    Alek
    Participant

    Thanks for the suggestion. I tried adding that code and it seems to have no effect. It’s probably conflicting with either or both plugins mentioned above. Unfortunately WP is not wrapping the label or field in or anything at all, so there is not way I can hide via CSS. Any other ideas?

    #32175
    Barry
    Member

    I’m afraid not.

    The snippet works for me, but then I’m not running the same plugins as you are and am referring to the presence of the fields in the regular User Profile admin page, I’m not really sure what you’re seeing or what’s being generated for you on the frontend.

    Just for the sake of clarity: with that snippet in place, if you login as a user other than one of those for whom you have made an exception, do you still see the Eventbrite fields in the regular Your Profile page?

    #32425
    Alek
    Participant

    Yes, I am still seeing the API Key field within WP profile pages. Using the following code. The only change was to add user ID 12 to the allow list.

    /**
    * Hides the Eventbrite Tickets fields from user profiles, unless the user is on the exception
    * list.
    */
    class EventbriteProfileFieldsHider {
    protected $exceptionList = array(1);

    /**
    * Any users who still need to see the Eventbrite Tickets fields in their profile should be
    * specified as an array of integers. By default, if no arguments are passed in, it is assumed
    * that they should still be visible for user #1 (the normal root admin).
    *
    * @param array $exceptions
    */
    public function __construct(array $exceptions = null) {
    // Change the default exception list (which is just user #1 - the default admin in most cases)
    if ($exceptions !== null) $this->exceptionList = $exceptions;

    // Conditionally remove the Eventbrite Tickets fields from the user profile
    add_action('admin_init', array($this, 'maybeRemoveFields'), 50);
    }

    public function maybeRemoveFields() {
    $user = wp_get_current_user();

    if (is_object($user) and isset($user->ID) and !in_array($user->ID, $this->exceptionList)) {
    $eventbriteTickets = Event_Tickets_PRO::instance();
    remove_action('show_user_profile', array($eventbriteTickets, 'userProfilePage'));
    remove_action('edit_user_profile', array($eventbriteTickets, 'userProfilePage'));
    }
    }
    }

    // Let the (Eventbrite Tickets profile) fields be visible for the following users (by ID)
    $allow = array(1, 2, 12);

    // Hide the fields for everyone else
    new EventbriteProfileFieldsHider($allow);

    #32427
    Barry
    Member

    Sorry Alek, I’m afraid there isn’t much more I can offer you here.

    That code works for me (if I login as user #2 for instance, and 2 is one of the allowed IDs, then I can see the Eventbrite fields on the profile page. If I remove 2 from the list of allowed IDs then I can no longer see them) but if it doesn’t work for you then you will have to workaround this by other means.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘How can I remove the Eventbrite API key field from registraion/profile form?’ is closed to new replies.