• I was wondering what the process would be to allow a user to registered with the user roll “Venue” to be able to add a single venue and have it link with their account.

    They would be able to only add events to their Venue,

    also I would like to make “Event Managers” who can add events for venues if the Venue user added them to some sort of list.

    any ideas how I would go about this?

    https://wordpress.org/plugins/event-organiser/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter pryme8

    (@pryme8)

    I figured it out, but now I need some help with the form Validation…

    what variables are actually passed to

    add_action('um_submit_form_errors_hook', 'validate_venue', 99,1);
    function validate_venue( $args ){}

    the $args array?

    I am trying to have a single validation check multiple conditions and then post the correct errors on the inputs.

    I have it working for venue name, but now verifying its a unique address is making me struggle…

    global $ultimatemember;
    	global $wpdb;
    
    		if ( isset( $args['venue-name'] ) ){
    			$venueName = $args["venue-name"];
    			$venueAddress = $args["street-address"];
    			$venueCity = $args["city"];
    
    			$return_name = $wpdb->get_col($wpdb->prepare("
    				SELECT meta_key
    				FROM {$wpdb->eo_venuemeta}
    				WHERE meta_key = '_venue-name'
    				AND meta_value = %s
    				", $venueName ));
    
    			$return_address = $wpdb->get_col($wpdb->prepare("
    				SELECT meta_key
    				FROM {$wpdb->eo_venuemeta}
    				WHERE (meta_key = '_address' AND meta_value='%s')
    				", $venueAddress));
    
    			$return_city = $wpdb->get_col($wpdb->prepare("
    				SELECT meta_key
    				FROM {$wpdb->eo_venuemeta}
    				WHERE (meta_key = '_city' AND meta_value='%s')
    				", $venueCity));
    
    		if($return_name) {
    			$ultimatemember->form->add_error("venue-name",'This Venue Name '.$venueName.', is already Taken!','ultimatemember');
    		}
    
    		if($return_address && $return_city) {
    
    			if($return_address){
    				$return_address->form->add_error("street-address",'This Venue Address '.$venueAddress.', is already Taken!','ultimatemember');
    			}
    
    			if($return_city){
    				$return_address->form->add_error("city", $venueAddress.'in'.$venueCity.', is already Taken!','ultimatemember');
    			}
    		}

    returns an error of
    Fatal error: Call to a member function add_error() on a non-object in /home/prymeadmin/public_html/wp-content/themes/bizmo/functions.php on line 168

    Any ideas?

    I split up the returns to make sure I can variably flag whats wrong…

    I know I could prolly do it with

    WHERE (meta_key = '_address' AND meta_value='%s')
    AND (meta_key = '_city' AND meta_value='%s')

    which would be more ideal, but I need to make sure that the errors propagate the correct info first… and that I am actually gathering the correct values from the inputs.

    hence the question about the structure of the $args array.

    Plugin Author Stephen Harris

    (@stephenharris)

    um_submit_form_errors_hook is not an Event Organiser hook (I assume its one provided by Ultimate Member). You will have to ask them as to the structure of the array passed to callbacks hooked onto that filter.

    Also, the actual error messages relates to this:

    $ultimatemember->form->add_error( ... );

    whatever $ultimatemember->form is storing, it doesn’t have an add_error message. Again you’ll need to talk to the Ultimate Member guys about how to add an error message to the form.

    Thread Starter pryme8

    (@pryme8)

    whoops, my bad your right I dont know why I posted that here… The question for you guys was more on how to interact with the eo_venuemeta but I figured that out.

    The problem was the structure of the wpdb->sql statement was a little different then what I am used to doing with sqli procedural.

    The question I would still have for you then, if I am manually adding the venues with my own database requests, am I going to have to insert into multiple tables or just the data in the eo_venuemeta table that was created when I made a test venue through your UI?

    I ended up adding a _venue-name row, because I was not able to find the location that stores the venues name, is it stored as a post?

    Plugin Author Stephen Harris

    (@stephenharris)

    Venues are just terms, so you’ll find them in wp_terms (but I recommend you use the WordPress API or if prefer the plugin provided API: http://codex.wp-event-organiser.com/package-venue.functions.html where possible). For example you can get a venue from its name with eo_get_venue_by().

    The Venue ID is the same as the term ID.

    Thread Starter pryme8

    (@pryme8)

    I assume I can use that to search by name like I was looking for, and also address? So I could restructure my code with something like:

    if ( isset( $args['venue-name'] ) && eo_get_venue_by('name',$args['venue-name'] ) ){
    	$venueName = $args["venue-name"];
    $ultimatemember->form->add_error("venue-name",'This Venue Name '.$venueName.', is already Taken!','ultimatemember');
    }

    I would much rather use your API, the link you just sent me is pretty legit thank you!

    Plugin Author Stephen Harris

    (@stephenharris)

    Venue name yes, address no. Also be sure to escape your SQL statements and the value passed to eo_get_venue_by() as otherwise you’ll be opening a back door to your database!

    Thread Starter pryme8

    (@pryme8)

    So would it be more ideal to stick with my wpdb prepared statments?

    Why are the requests to eo_get_venue_by not automatically getting prepared and sterilized?

    I guess this is when I feature request that things like that automatically get sterilized an that the eo get venue by function could have address and geo locations requests?

    Also, in the naming of the venue is it going to be smarter for me to add an associated meta-key in the venumeta table like I did or would it be more practical to link to the name stored on the separate wp table?

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Associate User to Single Venue’ is closed to new replies.