• Resolved hengstigal

    (@hengstigal)


    Hello is it possible to show the used Invitationcode:

    – In The WP-Admin Backend at the User Profile (this would be important for me)

    – On the Buddypress Profile

    Thank you very much!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Mirza Hamza

    (@hamza1010)

    Hi @hengstigal,

    Thanks for contacting us,

    I hope you are doing well, We have forwarded this to our technical team we will get back to you.

    Thanks & Regards

    WP Experts Support Team

    Plugin Support Mirza Hamza

    (@hamza1010)

    Hi @hengstigal,

    Yes, it is possible to do this please use this shortcode : [user_invitation_code].

    After adding below code snippet to your site.

    Code Snippet:

    function user_invitation_code_cb()
    {
    	if ( !is_user_logged_in() ) 
    	{
    		return;
    	}
    		
    	$meta_query = [];
    	$uid=get_current_user_id();
    	$meta_query[] = [
    		'key'     => '_registered_users',
    		'value'   => 'i:'.$uid.';',
    		'compare' => 'LIKE'
    		];
    	$query = [
    		'post_type'      => 'invitation_code',
    		'posts_per_page' => '-1',
    		'meta_query'     => $meta_query
    		];
    	$matched = get_posts( $query );
    
    	if(!empty($matched[0]->post_title))
    	{
    		return $matched[0]->post_title;
    	}
    	
    	return 'No Invitation Code';
    }
    
    function reg_inv_shortcode()
    {
        add_shortcode('user_invitation_code', 'user_invitation_code_cb');
    }
    add_action('init','reg_inv_shortcode');

    Thank you

    Thread Starter hengstigal

    (@hengstigal)

    And how can i display the code on the backend user profile? 🙂

    Plugin Support Mirza Hamza

    (@hamza1010)

    Hi @hengstigal,

    You can add below snippet to your site, this will show used invitation code on backend user profile.

    Also, you can show that used invitation code anywhere on the site by using this shortcode: [user_invitation_code]

    Please have a look at the screenshot.

    function user_invitation_code_cb()
    {
    	if ( !is_user_logged_in() ) 
    	{
    		return;
    	}
    		
    	$meta_query = [];
    	$uid=get_current_user_id();
    	$meta_query[] = [
    		'key'     => '_registered_users',
    		'value'   => 'i:'.$uid.';',
    		'compare' => 'LIKE'
    		];
    	$query = [
    		'post_type'      => 'invitation_code',
    		'posts_per_page' => '-1',
    		'meta_query'     => $meta_query
    		];
    	$matched = get_posts( $query );
    
    	if(!empty($matched[0]->post_title))
    	{
    		return $matched[0]->post_title;
    	}
    	
    	return 'No Invitation Code';
    }
    
    function reg_inv_shortcode()
    {
        add_shortcode('user_invitation_code', 'user_invitation_code_cb');
    }
    add_action('init','reg_inv_shortcode');
    
    function custom_user_profile_fields( $profileuser ) {
    ?>
        <table class="form-table">
            <tr>
                <th>
                    <label for="label"><?php _e( 'Invitation Code Used' ); ?></label>
                </th>
                <td>
    				<label for="ivitation-code"><u><?php echo (do_shortcode('[user_invitation_code]')); ?></u></label>
                </td>
            </tr>
        </table>
    <?php
    }
    add_action( 'show_user_profile', 'custom_user_profile_fields' );
    add_action( 'edit_user_profile', 'custom_user_profile_fields' );

    Thank you

    • This reply was modified 1 year, 7 months ago by Mirza Hamza.
    Plugin Support Mirza Hamza

    (@hamza1010)

    Hi @hengstigal,

    We are resolving this thread due to lack of activity if you have any questions please open a new thread.

    Thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Show Invitation Code in Userprofile and Buddypress’ is closed to new replies.