Can events in Events+ default to be a paid event?

We have a site that we collect for certain events. Most of our events are paid events. For whatever reason, my admin folks cant seem to mark events as a paid event. Therefore people show up without paying for the event. I would like a new event to default to a paid event with a cost of $10.00. Is this possible?

  • Vinod Dalvi

    Hi Phil,

    I hope you are well today and thank you for your question.

    For whatever reason, my admin folks cant seem to mark events as a paid event. Therefore people show up without paying for the event.

    You can mark the event as paid event by setting the event option "Is this a paid event? " to Yes in the edit event screen as shown in the attached screenshot.

    What do you exactly mean by "my admin folks cant seem to mark events as a paid event"?

    Also would you mind if I logged in to your site and did some troubleshooting? This might help get to the bottom of this faster. If this is ok, just grant me temporary admin access to your site by clicking "Grant Access" button in the WPMU DEV Dashboard Settings as described on the following page and reply on this thread after granting it?

    https://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    I would like a new event to default to a paid event with a cost of $10.00. Is this possible?

    Yes it's possible by developing some custom code if you are comfortable with it.

    Kind Regards,
    Vinod Dalvi

  • Vinod Dalvi

    Hi Phil,

    You can achieve this using the attached small plugin specially developed for you which contains the following code.

    function set_default_event_values(){
    	global $pagenow, $post;
    
    	if( $pagenow == 'post-new.php' && $post->post_status == 'auto-draft' ){
    		$is_paid = true;
    		$fee = 10;
    		update_post_meta($post->ID, 'incsub_event_paid', ($is_paid ? '1' : ''));
    		update_post_meta($post->ID, 'incsub_event_fee', $fee);
    	}
    }
    add_action('admin_head', 'set_default_event_values');

    Best Regards,
    Vinod Dalvi

  • Phil

    Hi Vinod,

    I have added the code you gave me to my functions.php file. The code does not seem to work. I have also added a logging function so I can see the value of the variables but this does not get logged. This would lead me to believe that admin_head is not firing. Seems strange to me. Below is a function called Log_Me that logs whatever I want into the debug.log file as well as my changes to your code.

    Your code with my modifications:

    function set_default_event_values(){
    	global $pagenow, $post;
    	log_me("XXXXXXXXXXXXXXXXX start event value debuging XXXXXXXXXXXXXX")
    	log_me($pagenow)
    	log_me($post->post_status)
    	log_me("XXXXXXXXXXXXXXXX End event value debuging XXXXXXXXXXXXXXXXXXXXX")
    	if( $pagenow == 'post-new.php' && $post->post_status == 'auto-draft' ){
    		$is_paid = true;
    		$fee = 10;
    		update_post_meta($post->ID, 'incsub_event_paid', ($is_paid ? '1' : ''));
    		update_post_meta($post->ID, 'incsub_event_fee', $fee);
    	}
    }
    add_action('admin_head', 'set_default_event_values');

    And the Logging Function:

    function log_me($message) {
        if (WP_DEBUG === true) {
            if (is_array($message) || is_object($message)) {
                error_log(print_r($message, true));
            } else {
                error_log($message);
            }
        }
  • Ash

    Hello @Phil

    Would you please try the following code?

    function set_default_mem_values(){
    	?>
    	<script type="text/javascript">
    	jQuery(function($) {
    		setTimeout(function() {
    			$('#incsub_event_paid option[value=1]').attr('selected', 'selected');
    			$('#incsub_event_fee').val('10.00');
    			if($('.ui-multiselect-checkboxes').length) {
    				$('.ui-multiselect-checkboxes li span').each(function() {
    					if($(this).text() == 'Bronze Level' || $(this).text() == 'Silver Level'){
    						$(this).prev().prop('checked', true);
    					}
    				});
    			}
    		}, 2000);
    	});
    	</script>
    	<?php
    }
    add_action('admin_head', 'set_default_mem_values');

    You will need to change the level name in the above code, not ID.

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • Phil

    Hello Ash,

    when I use this code, I get the white screen of death. When I look at the debug.log, I get the following output:
    [21-May-2015 20:32:02 UTC] PHP Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /My Path To/functions.php on line 3560

  • Vinod Dalvi

    Hi Phil,

    I have tested on my test site using the code shared by my colleague Ash but i didn't get any issue with it as you have mentioned in your previous reply.

    I checked the functions.php file of your Mantra Child Theme on your site and found at the end of this file the PHP tag is closed as shown in the attached screenshot so in this case you have to either remove the last closing PHP tag or add the opening PHP tag before the provided code as following.

    <?php
    function set_default_mem_values(){
    	?>
    	<script type=&quot;text/javascript&quot;>
    	jQuery(function($) {
    		setTimeout(function() {
    			$('#incsub_event_paid option[value=1]').attr('selected', 'selected');
    			$('#incsub_event_fee').val('10.00');
    			if($('.ui-multiselect-checkboxes').length) {
    				$('.ui-multiselect-checkboxes li span').each(function() {
    					if($(this).text() == 'Bronze Level' || $(this).text() == 'Silver Level'){
    						$(this).prev().prop('checked', true);
    					}
    				});
    			}
    		}, 2000);
    	});
    	</script>
    	<?php
    }
    add_action('admin_head', 'set_default_mem_values');

    Also if you are commenting multiple lines of PHP code then please use PHP multiline comments syntax as described on the following pages.

    http://php.net/manual/en/language.basic-syntax.comments.php
    https://codex.wordpress.org/Commenting_Code
    http://www.w3schools.com/php/php_syntax.asp

    Regards,
    Vinod Dalvi

  • Ash

    Hello @Phil

    There was a type in above code, please try this:

    function set_default_mem_values(){
    	?>
    	<script type="text/javascript">
    	jQuery(function($) {
    		setTimeout(function() {
    			$('#incsub_event_paid option[value=1]').attr('selected', 'selected');
    			$('#incsub_event_fee').val('10.00');
    			if($('.ui-multiselect-checkboxes').length) {
    				$('.ui-multiselect-checkboxes li span').each(function() {
    					if($(this).text() == 'Bronze Level' || $(this).text() == 'Silver Level'){
    						$(this).prev().prop('checked', true);
    					}
    				});
    			}
    		}, 2000);
    	});
    	</script>
    	<?php
    }
    add_action('admin_head', 'set_default_mem_values');

    If it doesn't work, then you will need to customize the core plugin. The customization will be lost every time you update the plugin and you have to do the same changes every time.

    Please let me know.

    Cheers
    Ash

  • Phil

    Hi Ash,
    I have run into an issue with this solution. While it does appear to work correctly, one thing does not. When we select the member level to make free when creating an event, the "Free for" dropdown box shows the levels that are set to free. When using just the code, it does not. That does not really matter to me but there seems to be some sore of action associated with the actual click event. When we create an event using just the code, all members are still asked to pay for the event. When I go back into the event and deselect the member levels and reselect them. Then the "Free For:" drop down is populated and the members are no longer prompted to pay for the event. I have tried to find any click event code in java script files, but did not find anything. I am not very proficient in javascript however.

  • Vinod Dalvi

    Hi Phil,

    I couldn't reproduce the issue on my test site using the shared code. It's working fine without any issue, even after editing the events and changing membership levels several time.

    Could you please describe the issue a bit more in detail so that i can reproduce and resolve it ( Share screenshots of it if you can )?

    Also please grant support staff access on your site so that i can test it there.

    Regards,
    Vinod Dalvi

  • Phil

    Hey Vinod,

    So after creating the event, the Event Type area looks like capture.png. When you click on the select levels button, it looks like capture1.png. If I deselect full and bike and then reselect them, the button looks like capture2.png. If I do not deselect and reselect, when the user (a full member) goes to the event, they get capture4.png. And if they RSVP, they get capture6.png. Does that help?

  • Patrick

    Hi again @Phil

    Okay, so if I understand correctly, the custom code is basically working. But there are a couple of kinks that need ironing out. :slight_smile:

    - While the Free for select levels dropdown does show the correct member levels that should have free access to the event (checkboxes checked), the settings are somehow not saved or applied.

    - Once you manually check those levels, they are indeed saved and applied, but no price meta is displayed on the event (frontend) where something like free or $0 should be displayed.

    Is that a fair summary of the current situation?

  • Phil

    Pretty Close. Your first statement is correct. once I manually check the boxes, everything is saved correctly. I suspect that there must be some sort of onclick event associated with those check boxes, but not real sure. just setting the checked property does not accurately update the event.

    On the Front End, everything works correctly. If I manually check the boxes, the user is not prompted to pay for the event. The div with the paypal info is not shown. This is the correct behavior. If I dont manually check the boxes, the div with the paypal information is shown and the user is asked to pay $10.00, the price of our event.

  • Vinod Dalvi

    Hi @Phil,

    We have released updated version of Events and Membership plugins so the custom code shared here that we are working on will not work with these updated plugins as these updated plugins contain some UI changes as shown in the attached screenshot.

    In the future you have to update your plugin so instead of wasting the time on it could you please update the plugins to the latest version and we'll look for the solution to achieve it with these updated plugins?

    To help keep support tickets separate, could you please open a new thread for your new question https://premium.wpmudev.org/forums/#question

    You can also include reference of this thread in your newly created thread if you want to.

    We would be more than happy to help you on your new thread :slight_smile:

    Regards,
    Vinod Dalvi

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.