WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Using EM shortcodes in php context (11 posts)

  1. freakzone89
    Member
    Posted 10 months ago #

    hey guys,

    i designed a single page using php-code on it. now i want to display different event-categories depending on different user-roles and therefore i want to use shortcode from event-manager. but unfortunately it doesn't work. could anybody help?

    this is what i've got so far:

    <?php
    if ( user_role_check( 'd1' )):
    
       echo do_shortcode('[events_list category="8"]') ; 
    
     elseif ( user_role_check( 'd2' )): 
    
       echo do_shortcode('[events_list category="9"]');
    
     elseif... //and so on
    
     endif;
    ?>

    cheers

    p.s.: the user-roles are added by myself, so they aren't standard - but this doesn't seem to be the problem

    http://wordpress.org/plugins/events-manager/

  2. caimin_nwl
    NetWebLogic Support
    Posted 10 months ago #

    Hi,

    If you put

    echo do_shortcode('[events_list category="8"]') ;

    outside of the if statements does it work?

  3. freakzone89
    Member
    Posted 10 months ago #

    i tried it but it doesn't work!

  4. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 10 months ago #

    how about just

    echo do_shortcode('[events_list]') ;

    if not, then make sure you're adding your code to the right place

  5. freakzone89
    Member
    Posted 10 months ago #

    i first tried this, to prove that the combination of the if statements work, and it does!

    if ( user_role_check( 'd1' )):
    
       echo 'd1' ; 
    
     elseif ( user_role_check( 'd2' )): 
    
       echo 'd2';
    
      elseif ( user_role_check( 'h1' )):
    
        echo 'h1';
    
       elseif ( user_role_check( 'h2' )):
    
         echo 'h2';
    
       elseif ( user_role_check( 'admin' )):
    
          echo 'admin;
    
     endif;

    now i tried it Marcus' way and changed it to:

    if ( user_role_check( 'd1' )):
    
       echo 'd1' ; 
    
     elseif ( user_role_check( 'd2' )): 
    
       echo 'd2';
    
      elseif ( user_role_check( 'h1' )):
    
        echo 'h1';
    
       elseif ( user_role_check( 'h2' )):
    
         echo 'h2';
    
       elseif ( user_role_check( 'admin' )):
    
          echo do_shortcode('[events_list]');
    
     endif;

    and it doesn't work. i just changed the admin position as i'm working as an admin and to minimize the potential error sources. i think the code is also positioned the right way.

    any other ideas?

    cheers

  6. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 10 months ago #

    try

    echo EM_Events::output();

    that should definitely work... otherwise something else is going wrong

  7. freakzone89
    Member
    Posted 10 months ago #

    yes, it does work. but it doesn't fulfill the need of showing a seperate category of events.

  8. angelo
    NetWebLogic Support
    Posted 10 months ago #

    sorry, can you give us more details about this? eg. do you want it to group per category

  9. freakzone89
    Member
    Posted 10 months ago #

    i want to show a group of events that belongs to a certain event-category. for example users with role "h1" should only see events from category 8 and users with role "d2" should only see events from category 7 and so on.
    so i need the code to only show events from a certain category.

    hope that's the information you need.

  10. philipjohn
    Member
    Posted 10 months ago #

    Hiya,

    If you take a look at the output() function in the EM_Events class you will see a number of options you can provide as parameters, including specifying a category.

    Thanks,
    Phil

  11. freakzone89
    Member
    Posted 10 months ago #

    oh yeah!

    this is how it works, thank you phil! instead of
    echo do_shortcode('[events_list category="8"]') ;
    i used
    echo EM_Events::output( array('category'=>8)) ;

    cheers

Reply

You must log in to post.

About this Plugin

About this Topic