WordPress.org

Ready to get started?Download WordPress

Forums

CubePoints
History of my points in one page (4 posts)

  1. Turismo in
    Member
    Posted 1 year ago #

    Hello,
    i have this:

    <?php
    
    /** My Points Module */
    
    cp_module_register(__('My Points', 'cp') , 'mypoints' , '1.0', 'CubePoints', 'http://cubepoints.com', 'http://cubepoints.com' , __('Allow users to see a history of their point transactions.', 'cp'), 1);
    
    add_action('cp_module_mypoints_activate','cp_module_mypoints_install');
    
    if(cp_module_activated('mypoints')){
    
    	add_action('admin_print_scripts-cubepoints_page_cp_modules_mypoints_admin', 'cp_datatables_script');
    	add_action('admin_print_styles-cubepoints_page_cp_modules_mypoints_admin', 'cp_datatables_style');
    
    	add_action('cp_admin_pages','cp_module_mypoints_add_admin_page');
    
    		echo '<div class="wrap">';
    		echo '<h2>CubePoints - ' . __('My Points', 'cp') . '</h2>';
    		echo __('Manage and view information about your points.', 'cp');
    		echo '<br /><br />';
    		echo '<div style="background:#EFEFEF;display:inline-block;margin-right:25px;"><div style="float:left;font-size:17px;font-weight:bold;background:#E0E0E0;padding:18px;color:#565656;">' . __('My Points', 'cp') . ':</div><div style="float:left;padding:18px;font-size:20px;">' . cp_getPoints(cp_currentUser()) . '</div></div>';
    		if(cp_module_activated('ranks')){
    			echo '<div style="background:#EFEFEF;display:inline-block;"><div style="float:left;font-size:17px;font-weight:bold;background:#E0E0E0;padding:18px;color:#565656;">' . __('My Rank', 'cp') . ':</div><div style="float:left;padding:18px;font-size:20px;">' . cp_module_ranks_getRank(cp_currentUser()) . '</div></div>';
    		}
    		echo '<div style="clear:both;"></div><br />';
    
    		echo '<p style="font-weight:bold;">' . __('Your recent point transactions:', 'cp') . '</p>';
    
    		cp_show_logs(cp_currentUser(), 15 , false);
    
    		echo '</div>';
    	}
    
    ?>

    If i insert it.. i can add what i want (my points) in one page with template.
    Now i want add it without template but with only one shortcode. How to do it?

    http://wordpress.org/extend/plugins/cubepoints/

  2. Gabriel
    Member
    Posted 1 year ago #

    Hey!

    Just add a shortcode to your module i.e:

    add_shortcode( 'myshortcode', 'myshortcode_function' );
    function myshortcode_function( $atts )
    {
    	// Extract Attributes if you want any
    	extract( shortcode_atts( array(), $atts ) );
    	// Your code here
    }

    Just remember that if you place it inside if(cp_module_activated('mypoints')){ } it (the shortcode) will only be available when the module is active.

  3. Turismo in
    Member
    Posted 1 year ago #

    Thank you but the shortcorde how is?
    [mypoints][/mypoints]?

  4. Gabriel
    Member
    Posted 1 year ago #

    The shortcode would be [myshortcode]. If you want to pass on attributes it would be [myshortcode number="1"]. In this example number would be the attribute.

    You can find more information about Shortcodes here: http://codex.wordpress.org/Shortcode_API

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.