• Hello!

    I’d love to show the user role behind his or her name on the event booking list. Right now I have the title of the event, information, and a list of everyone who is signed up.

    I have a few roles on my website that I’d like to publish behind the person:

    Attendee’s:
    John – Admin – 1 ticket
    Adam – Supporter – 1 ticket
    Kimberley – Writer – 1 ticket
    Jennifer – Visitor – 2 tickets

    I’ve tried coding this in, but I cant get it to work. I once got the role of the current user to display behind them all but could not turn that around to what I want.

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    hi,

    you can try to modify template file under events-manager/templates/placeholders/attendeeslist.php

    to use templates: http://wp-events-plugin.com/documentation/using-template-files/

    eg. wp-content/themes/Your Theme/plugins/events-manager/placeholders/attendeeslist.php

    Thread Starter janhoos

    (@janhoos)

    Hi Gelo!

    Thanks, I found that one pretty soon.

    I was wondering if someone could give me some pointers on how to retrieve the role of each attendee.

    You’d need to use something like get_userdata:

    https://codex.wordpress.org/Function_Reference/get_userdata

    Thread Starter janhoos

    (@janhoos)

    Thanks! I tried that before, that resulted in it just displaying the role of the signed in user. But I’ll experiment some more with it.

    I guess this bit should help:

    <?php $user_info = get_userdata(1);
    echo ‘Username: ‘ . $user_info->user_login . “\n”;
    echo ‘User roles: ‘ . implode(‘, ‘, $user_info->roles) . “\n”;
    echo ‘User ID: ‘ . $user_info->ID . “\n”;
    ?>

    The function get_userdata(1); should be adjusted so it looks at the users that signed up. Maybe execute this per attendee.

    Plugin Support angelo_nwl

    (@angelo_nwl)

    this might be an old article but should be something like this – http://stackoverflow.com/questions/1458362/how-to-get-the-currently-logged-in-users-role-in-wordpress

    you can use $EM_Booking->get_person()->ID as the user id

    Thread Starter janhoos

    (@janhoos)

    Thanks for the help!

    I tried working with this. I could not get it to work so I tried if I could show the wordpress data using the link caimin posted.

    I pasted the code from the codex page

    $user_info = get_userdata(1);
    echo 'Username: ' . $user_info->user_login . "\n";
    echo 'User ID: ' . $user_info->ID . "\n";

    Its not displaying anything, even tho its unmodified, straight out of the codex page. So I’m not sure whats going wrong at the moment.

    When I used the Events Manager attribute

    echo '<li>' . $EM_Booking->get_person()->id;

    it did work. So is Events Manger blocking WP codes?
    I’ve got an example here: http://www.airsoftclubnederland.nl/evenementen/bunker-hill/

    You can see it, not working by the title: Wie gaan er allemaal?

    Thread Starter janhoos

    (@janhoos)

    Allright! Had some more time to tinker with this. I got it to work!

    $aanmelding = $EM_Booking->get_person()->ID;
    		$user = new WP_User( $aanmelding );	
    
    		if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
       		foreach ( $user->roles as $role )
    
    			echo '
    
    <li>'. $EM_Booking->get_person()->get_name() .' - ' . $role  .' - Aantal personen : '  . $EM_Booking->get_spaces() .  '</li>
    ';
    }

    I’d love to tweak it so its not showing the role id but the role name. Havent figured that out yet, after a few hours of googling and trying stuff out.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Show user role?’ is closed to new replies.