WordPress.org

Ready to get started?Download WordPress

Forums

CubePoints
Paid Content Shortcode (24 posts)

  1. jasnon
    Member
    Posted 1 year ago #

    Hello,

    I've been searching around everywhere for a solution to this and unfortunately have not found one yet. It seems a number of other people are also trying to get the paid content module to work on a specific piece of content within a post/page rather then the whole post/page itself. Oddly I havn't come across the idea of using a shortcode to satisfy this. Would it be possible to create a shortcode to wrap around whatever content you wanted users to pay for? It would go something like this...

    [paid-content] You're paid content would go here. [/paid-content]

    It would behave exactly the same way as it does now but offer much more flexibility on what content could be paid for. Please somebody can you help with this??

    Thanks

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

  2. jasnon
    Member
    Posted 1 year ago #

    I should also add that I'm looking for a short code parameter of "amount" to be filled in depending on how much you want the paid content to be for. So it would go:

    [paid-content amount="10"] You're paid content would go here. [/paid-content]

    This would cost the user 10 points to access the enclosed content.

    Thanks

  3. J.D. Grimes
    Member
    Posted 1 year ago #

    I have a module that works exactly like you want. Here is a link to download it.

  4. jasnon
    Member
    Posted 1 year ago #

    J.D. -

    Amazing! Thanks for the module, this is indeed exactly what I was looking for! When I was testing out the shortcode I did however notice a problem when using it on my Home Page. Once I clicked the button to spend points and show the protected content it changed my home page to all my recent posts from my blog. I am using a static Home page instead of my latest posts so maybe there is an issue with this. Oddly this only happened when I was on my admin account (it also removed all my buttons on the admin bar), when I tried the same thing on another subscriber account this did not happen.

    Also, I was hoping to use this in some cases within a Contact Form 7 form - such that a user would need to spend points to access the submit button in order to submit their form. When I tried this, clicking the button to spend points for the protected content actually submitted the CF7 form. Is there a way for this to work?

    Thanks again for posting the module though, this feature is really awesome.

  5. J.D. Grimes
    Member
    Posted 1 year ago #

    Sorry, I accidentally left out an ending form tag. I fixed it and it should work for you now, just re-download it. :)

  6. magonicolas
    Member
    Posted 1 year ago #

    J.D Grimes, How Do I Install your Code?

    Thanks

  7. J.D. Grimes
    Member
    Posted 1 year ago #

    You need to unzip the file and upload it to /wp-content/cubepoints/modules folder on the server. You can use FTP, or if you aren't familiar with that and you have cPanel hosting you can use the file manager to upload it to the right directory. Then you need to activate the module on the CubePoints > Modules page in the admin dashboard. You can configure the defaults on the CubePoints > Configure page.

  8. beezeeking
    Member
    Posted 1 year ago #

    hi,J.D. Grimes
    the module is very good,this is indeed what I was looking for too,but i want to use the php code in other plugins ,how can i let it come true?

  9. J.D. Grimes
    Member
    Posted 1 year ago #

    @beezeeking - What part of the code are you trying to use? Exactly what are you trying to do? Do you know PHP?

  10. beezeeking
    Member
    Posted 1 year ago #

    so quick,thank you!
    i used the plugin "wp user frontend",i have a front-end post form to users that users can publlish post,and i add a custom field "site_address",i want to other users must need paying the points to view the "site_address" field.
    In my mind,i use the php code of the protect including the custom field "site_address",i don't know if my think is right?thank you for giving directions

  11. J.D. Grimes
    Member
    Posted 1 year ago #

    Yes, you could do that. In your PHP code you would do something like this:

    do_shortcode( '[protect points="50"]Content[/protect]' );

    Just replace "Content" with the code for your custom field. If you need more help try pasting your code here.

  12. beezeeking
    Member
    Posted 1 year ago #

    haha,very thank you!
    i add the custom text area field "cf_site_address",but i don't know how to add the protect code ?i only want to protect the "cf_site_address" field,thank you for giving directions?follow is the part of "wp user frotend" plugin code:

    function wpuf_show_meta_front( $content ) {
        global $wpdb, $post;
    
        //check, if custom field is enabled
        $enabled = wpuf_get_option( 'enable_custom_field' );
        $show_custom = wpuf_get_option( 'cf_show_front' );
        $show_attachment = wpuf_get_option( 'att_show_front' );
    
        if ( $enabled == 'on' && $show_custom == 'on' ) {
            $extra = '';
            $fields = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}wpuf_customfields ORDER BY <code>region</code> DESC", OBJECT );
            if ( $wpdb->num_rows > 0 ) {
                $extra .= '<ul class="wpuf_customs">';
                foreach ($fields as $field) {
                    $meta = get_post_meta( $post->ID, $field->field, true );
                    if ( $meta ) {
                        $extra .= sprintf( '<li><label>%s</label> : %s</li>', $field->label, make_clickable( $meta ) );
                    }
                }
                $extra .= '<ul>';
    
                $content .= $extra;
            }
        }
  13. J.D. Grimes
    Member
    Posted 1 year ago #

    Here is a link to modified code. Let me know if it works for you.

  14. beezeeking
    Member
    Posted 1 year ago #

    J.D. Grimes
    this link display error,i changed the ip adress,but it also didn't open, i don't have the cdn,I'm so sorry?

  15. J.D. Grimes
    Member
    Posted 1 year ago #

    Just replace this part:

    if ( $meta ) {
                        $extra .= sprintf( '<li><label>%s</label> : %s</li>', $field->label, make_clickable( $meta ) );
                    }

    With this:

    if ( $meta ) {
    
                    	// If this is the site address.
                    	if ( 'cf_site_address' == $field )
                    		$meta = do_shortcode( '[protect points="50"]' . $meta . '[/protect]' );
                    	else
                    		$meta = make_clickable( $meta );
    
                        $extra .= sprintf( '<li><label>%s</label> : %s</li>', $field->label, $meta );
                    }
  16. beezeeking
    Member
    Posted 1 year ago #

    J.D. Grimes
    i think it is great and i used the code like you write,but it dosn't work?i am very confuse,the protect code dosn't function?

  17. J.D. Grimes
    Member
    Posted 1 year ago #

    Can you post a link to an example?

  18. beezeeking
    Member
    Posted 1 year ago #

    hi J.D. Grimes,
    http://beezeeking.uhostall.com/
    [ redacted, seriously do not post that here ]

    i published post in the front-end,but the protect code couldn't function?in the plugin "wp user frontend",i edit the file "wpuf-functions.php" as you writed code,thank you for giving directions.

  19. @beezeeking Please do not post login credentials on this forum again. I strongly encourage you to change the password for that account.

  20. beezeeking
    Member
    Posted 1 year ago #

    oh,J.D. Grimes
    it couldn't be published the username and password ,fllow is an example:
    http://beezeeking.uhostall.com/welcom-j-d-grimes/
    the field "cf_site_address" couldn't protect?

  21. J.D. Grimes
    Member
    Posted 1 year ago #

    Try this:

    if ( $meta ) {
    
                    	$meta = do_shortcode( '[protect points="50"]' . $meta . '[/protect]' );
    
                        $extra .= sprintf( '<li><label>%s</label> : %s</li>', $field->label, $meta );
                    }
  22. beezeeking
    Member
    Posted 1 year ago #

    J.D. Grimes´╝îthank you!

    i have edited the code, all fields have been protected,like this:
    http://beezeeking.uhostall.com/welcom-j-d-grimes/
    Does this Judgement sentence is wrong?

  23. J.D. Grimes
    Member
    Posted 1 year ago #

    I see now what I did wrong before. This code should protect only the address field:

    if ( $meta ) {
    
                    	// If this is the site address.
                    	if ( 'cf_site_address' == $field->field )
                    		$meta = do_shortcode( '[protect points="50"]' . $meta . '[/protect]' );
                    	else
                    		$meta = make_clickable( $meta );
    
                        $extra .= sprintf( '<li><label>%s</label> : %s</li>', $field->label, $meta );
                    }
  24. beezeeking
    Member
    Posted 1 year ago #

    great,J.D. Grimes,so cool
    i edited the code,everything is ok,thank you for your directions and help,hope you have a good time! haha

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic