We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Member post one per weblog.

Development and Programming

Olomana Loomis ISC's avatar
Olomana Loomis ISC
36 posts
16 years ago
Olomana Loomis ISC's avatar Olomana Loomis ISC

Aloha,

I am creating a membership site. I want my members to be able to post a testimonial. However, these testimonials need to be entered via the stand alone entry form so they can be organized and sorted via the “Tag” module form SolSpace. Is there a way for me to limit the number of posts that a member can make like how you can with freeform form SolSpace?

any thoughts help and suggestions are greatly appreciated.

Many Thanks, Dustin

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Dusin,

Whilst there’s no built in way to do this if you are using an SAEF to input the data then you could probably quite easily just have a template which holds your form embedded inside a SQL query which checks to see if the current user has already posted to the weblog or not. If they have then don’t show the form. If they haven’t then you show the form.

Something like that should do what you need I would imagine.

Hope that helps a bit.

Best wishes,

Mark

       
Olomana Loomis ISC's avatar
Olomana Loomis ISC
36 posts
16 years ago
Olomana Loomis ISC's avatar Olomana Loomis ISC

Thanks Mark as a long time lurker here I knew you would be the one to respond. Many Thanks. I will be sure to explore your suggestion. I will admit I have played a little with the SQl query but not that much and this will be a first with SAEF.

If you could give me a little more of a nudge in the suggested direction I would greatly appreciate it.

  • Dustin
       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen
Thanks Mark as a long time lurker here I knew you would be the one to respond.

Probably just means I should get out more doesn’t it? 😉

Many Thanks.

No problem at all 😊

I will be sure to explore your suggestion. I will admit I have played a little with the SQl query but not that much and this will be a first with SAEF. If you could give me a little more of a nudge in the suggested direction I would greatly appreciate it. - Dustin

Absolutely no problem again. Something along these lines should do it for you I reckon :

<?php
global $SESS;
$users_id = $SESS->userdata['member_id'];
?>

{exp:query sql="

SELECT COUNT(*) as post_count
FROM exp_weblog_titles
WHERE weblog_id = '1'
AND author_id = '<?php echo $users_id; ?>'
"}

{if post_count >= "4"}
Sorry but you aren't allowed to post any more data to this form
{if:else}
{embed="tests/form-template"}
{/if}

{/exp:query}

N.B.You will need PHP parsing turned on for this template to enable the member_id part to work

you would then place your SAEF form into the embedded-form template and that should hopefully do what you need. You will probably need to change the weblog_id=’1’ to suit your needs but everything else should work out as far as I can see.

Hope that helps a bit.

Best wishes,

Mark

       
Olomana Loomis ISC's avatar
Olomana Loomis ISC
36 posts
16 years ago
Olomana Loomis ISC's avatar Olomana Loomis ISC

And Mark rises to the occasions yet again with lightning speed. I will be sure to let you know how this turns out.

EE is lucky to have you on board.

All the best.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen
And Mark rises to the occasions yet again with lightning speed. I will be sure to let you know how this turns out.

Yep do let me know. Pretty sure it should work but if it doesn’t then let me know and I’ll take a look into it for you. Haven’t actually tested it just written out from my mind so hopefully should work.

EE is lucky to have you on board.

That’s very kind of you thanks 😊

All the best.

You too.

Best wishes,

Mark

       
TonyNibbles's avatar
TonyNibbles
98 posts
16 years ago
TonyNibbles's avatar TonyNibbles

I notice you’re creating a membership site, so I’ll post this here incase it’s useful.

I originally wanted each member to have their own profile page with a comments wall. So I wrote an extension to give each member a weblog entry in a ‘members’ weblog (when they register), then had a normal comment form on their profile page. I used it in conjunction with the Solspace Users module.

This might be handy for you. The extension requires tweaking as it uses a hard coded weblog-id for the members weblog (in this one the weblog_id was 3), so PHP experience advised 😉

Oh, and original post here

<?php

if ( ! defined('EXT'))
{
    exit('Invalid file request');
}


class Member_blog_entry
{
    var $settings        = array();
    
    var $name            = 'Member blog entry';
    var $version        = '1.0.0';
    var $description    = 'This will insert a blog entry for a newly registered member, making it possible to have a comments form on their member profile.';
    var $settings_exist    = '';
    var $docs_url        = '';
    
    // -------------------------------
    //   Constructor - Extensions use this for settings
    // -------------------------------
    
    function Member_blog_entry($settings='')
    {
        $this->settings = $settings;
    }
    // END
    
    
    // --------------------------------
    //  Activate Extension
    // --------------------------------
    
    function activate_extension()
    {
        global $DB;
        
        $DB->query($DB->insert_string('exp_extensions',
                                      array(
                                            'extension_id' => '',
                                            'class'        => "Member_blog_entry",
                                            'method'       => "add_member_blog",
                                            'hook'         => "user_register_end",
                                            'settings'     => "",
                                            'priority'     => 10,
                                            'version'      => $this->version,
                                            'enabled'      => "y"
                                          )
                                     )
                  );
    }
    // END
    
    
    // --------------------------------
    //  Update Extension
    // --------------------------------  
    
    function update_extension($current='')
    {
        global $DB;
        
        if ($current == '' OR $current == $this->version)
        {
            return FALSE;
        }
        
        if ($current > '1.0.0')
        {
            // Update queries for next version 1.0.1
        }
        
        $DB->query("UPDATE exp_extensions 
                    SET version = '".$DB->escape_str($this->version)."' 
                    WHERE class = 'Member_blog_entry'");
    }
    // END
    
    
    // --------------------------------
    //  Add the member blog
    // --------------------------------  
    
    function add_member_blog($which, $member_id)
    {    
        global $DB, $EXT, $LOC;
        // Fetch the freshly registered member data
        $results = $DB->query("SELECT username, screen_name FROM exp_members WHERE member_id = ".$member_id."");
        $entry_date = date('Y-m-d H:i A');
        $entry_date = $LOC->set_human_time($LOC->now);
        $entry_date = $LOC->now;
        // Add the member blog title (make a readable Title and a url_title with their ID, followed by _comment)
        $qry = "INSERT INTO exp_weblog_titles (entry_id, weblog_id, author_id, site_id, ip_address, title, url_title, entry_date, edit_date, versioning_enabled, year, month, day, expiration_date, comment_expiration_date, sticky, status, allow_comments, allow_trackbacks, forum_topic_id, dst_enabled) 
        VALUES 
            ('', 
            '3', 
            '$member_id', 
            '1', 
            '".$_SERVER['REMOTE_ADDR']."', 
            '".$results->row['screen_name']." comments', 
            '".$member_id."_comments', 
            '".$entry_date."', 
            NOW(), 
            'n', 
            '".date('Y')."', 
            '".date('m')."', 
            '".date('d')."', 
            '0', 
            '0', 
            'n', 
            'open', 
            'y', 
            'n', 
            '0', 
            'n')";
        $DB->query($qry);
        // Get entry ID
        $entry_id = $DB->insert_id;
        // Add to weblog data
        $qry = "INSERT INTO `exp_weblog_data` (`entry_id`, `site_id`, `weblog_id`) VALUES ('".$entry_id."', '1', '3')";
        $DB->query($qry);
        // Update total entries
        $DB->query("UPDATE exp_members set total_entries = '1', last_entry_date = NOW() WHERE member_id = '$member_id'");
    }
    // END

}
// END Class

?>
       
Olomana Loomis ISC's avatar
Olomana Loomis ISC
36 posts
about 16 years ago
Olomana Loomis ISC's avatar Olomana Loomis ISC

Thanks guys,

This got back burnered for now but i should be jumping back into this in the near future.

All the Best,

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.