WordPress.org

Ready to get started?Download WordPress

Forums

Store Locator Plus
User edit and add own stores, have more stores, the beginning And i need help :) (3 posts)

  1. fort123
    Member
    Posted 1 year ago #

    What i am writing is usefull for everyone i guess, but my programming skill are at beginner level to say the best.

    But what i made is now working, i made 2 template files. One to display all registered stores to the user

    the other one to edit a store. (where the problem starts, when i update it erases the cell. Hope someone will pick this up and help me writing. So Charleston software would even get better

    The only thing what you have to do is
    create an extra column at your storelocator table named user_id
    install those 2 template files and make modifactions to the naming if you wish
    store them as stores.php and editstore.php in your theme dir.

    Things to do, start to get the update to work, then we have a working example. (btw u have to give the user_id in storelocator_le table a number matching the logedin user, you can assign more stores to one user)

    When this is working i think we should add the option to add another store.... :)

    <?php
    /*
    Template Name: stores
    */
    ?>
    
    <?php get_header(); ?>
    <h1>Your Store(s)</h1>
    Those are your stores
    
    <?php
    global $wpdb;
    $user_id_vm = $current_user->ID ;
    echo '<br /> Some debugging info. user_id_vm: ';
    echo "$user_id_vm";
    $praktijken = $wpdb->get_results("SELECT * FROM w_store_locator WHERE user_id = $user_id_vm");
    echo '<br />';
    
    echo "<table>";
    echo "<tr>";
    echo "<td>".'Praktijknaam'."</td>";
    echo "<td>".'Adres'."</td>";
    echo "<td>".'Type praktijk'."</td>";
    echo "</tr>";
    foreach($praktijken as $praktijk){
    
    echo "<tr>";
    echo "<td><div id='praktijk'><a href=\"editstore?praktijk_id_vm=$praktijk->sl_id\">".$praktijk->sl_store."</td>";
    echo "<td>".$praktijk->sl_address."</td>";
    echo "<td>".$praktijk->sl_tags."</td>";
    echo "</a></div></tr>";
    }
    echo "</table>";
    ?>
    
    <?php get_footer(); ?>

    And for editing the store

    <?php
    /*
    Template Name: editstore
    */
    ?>
    
    <?php get_header(); ?>
    
    <?php // the post handling of this site, now its targetted to the same page but could be send to other page
    if ($_SERVER['REQUEST_METHOD'] == 'POST')
    {
    
        $sl_store = $_POST['name'];
        $sl_zip = $_POST['zipcode'];
    
        $id = $_POST['storelocator_id'];
        mysql_query("UPDATE w_store_locator SET sl_store='$sl_store',sl_zip='$sl_zip' WHERE sl_id='$id'") or
            die(mysql_error());
    
        echo 'De gegevens zijn succesvol opgeslagen in de database, <a href="../editstore">je kan nu hier terug</a>';
    
    } else
    {
    ?>
    <h1>Wijzig Praktijk</h1>
    <A HREF="javascript:history.back()">Terug naar uw praktijk(en) overzicht.</a>
    
    <?php
    $pagina = filter_input(INPUT_GET, 'praktijk_id_vm', FILTER_VALIDATE_INT);
    if($pagina === FALSE) {
        echo '<h2>This is not the right way!</h2>';
    }
    else {
    $praktijk_id = $_GET['praktijk_id_vm'];
    $user_id_vm = $current_user->ID ;
    $praktijken = $wpdb->get_results("SELECT * FROM w_store_locator WHERE sl_id = $praktijk_id AND user_id =$user_id_vm ");
    
    echo '<br />debug info: practise id praktijk id: ';
    echo $praktijk_id;
    echo '<br /> debug infor: user_id (users) de user_id_vm: ';
    echo $user_id_vm;
    
    if ($user_id_vm != $praktijken[0]->user_id) { // user_id niet gelijk dan geen pagina weergeven (vanwege evt directe browser benadering van deze pagina)
        echo "<h2>Dit is natuurlijk niet de bedoeling</h2>"    ;
            }
    else {
    
    echo '<br />';
    
    echo "<table>";
    echo "<tr>";
    echo "<td>".'Praktijknaam'."</td>";
    echo "<td>".'Adres'."</td>";
    echo "<td>".'Type praktijk'."</td>";
    echo "</tr>";
    foreach($praktijken as $praktijk){
    
    echo "<tr>";
    echo "<td>".$praktijk->sl_store."</td>";
    echo "<td>".$praktijk->sl_address."</td>";
    echo "<td>".$praktijk->sl_tags."</td>";
    echo "</a></div></tr>";
    }
    echo "</table>";
    }}
    ?>
    
    <h1> Wijzig praktijkgegevens van <?=$praktijken[0]->sl_store; ?></h1>
    
    <form action="" method="post" enctype="multipart/form-data">
    <input type="hidden" name="storelocator_id" id="storelocator_id" value="<?=$praktijken[0]->sl_id; ?>" />
    
        	<fieldset>
            	<legend>Praktijkgegevens</legend>
    
                <div>
                	<label for="title">Praktijknaam</label>
                    <input type="text" name="title" id="title" value="<?=$praktijken[0]->sl_store;?>" placeholder="b.v. Tandartspraktijk het Contactpunt" required="required" class="box_shadow" maxlength="255" />
                </div>
                <div>
                	<label for="description">Praktijk omschrijving</label>
                	<textarea id="description" name="description" class="box_shadow" style="min-height: 50px;" rows="10" cols="60" placeholder="Onze praktijk heeft 6 medewerkers en wij zijn gespecialiseerd in de esthetische tandheelkunde."><?=(isset($praktijken[0]->sl_description)) ? $praktijken[0]->sl_description : '';?></textarea>
                </div>
                <div>
                	<label for="price_description">Geef uw "Tag" op, hiermee omschrijft u in 1 woord waar uw praktijk op is gericht</label>
       	         <select size="1">
                 <option  value="<?=$praktijken[0]->sl_tags;?>" placeholder="tandarts" class="box_shadow" maxlength="255" /></option>
    	<option  value="tandarts">Algemene Tandheelkunde</option>
    	<option value="mondhygienist">mondhygienist</option>
     </select>  </div>
    
                <div>
                	<label for="email">Praktijk e-mail</label>
                    <input type="email" name="email" id="email" value="<?=$praktijken[0]->sl_email;?>" placeholder="praktijk@info.nl" class="box_shadow" maxlength="255" />
                </div>
                <div>
                	<label for="phone">Telefoonnummer praktijk</label>
                    <input type="text" name="phone" id="phone" value="<?=$praktijken[0]->sl_phone;?>" placeholder="012-3456789" class="box_shadow" />
                </div>
                <div>
                	<label for="website">Website</label>
                    <input type="url" name="website" id="website" value="<?=$praktijken[0]->sl_website;?>" placeholder="http://www.tandartshetcontact.nl" class="box_shadow" maxlength="255" />
                </div>
                <div>
                	<label for="address">Adres</label>
                    <input type="text" name="address" id="address" value="<?=$praktijken[0]->sl_address;?>" placeholder="Contactweg 12" required="required" class="box_shadow" maxlength="255" />
                </div>
                <div>
                	<label for="zipcode">Postcode</label>
                    <input type="text" name="zipcode" id="zipcode" value="<?=$praktijken[0]->sl_zip;?>" placeholder="1234AB" required="required" class="box_shadow" maxlength="6" />
                </div>
                <div>
                	<label for="city">Plaats</label>
                    <input type="text" name="city" id="city" value="$praktijken[0]->sl_city;?>" placeholder="Amsterdam" required="required" class="box_shadow" maxlength="255" />
                </div>
                <div>
                <input type="submit" value="Bewaar deze gegevens" />
                </div>
            </fieldset>
        </form>
    </div>
    </div>
    
    <? }?>
    <?php get_footer(); ?>

    http://wordpress.org/extend/plugins/store-locator-le/

  2. fort123
    Member
    Posted 1 year ago #

    lol i got it to work, happy now. please help me to write more code for this.
    Like adding stores for user
    and find stores and connect to them

    <?php
    /*
    Template Name: editstore
    */
    ?>
    
    <?php get_header(); ?>
    
    <?php // the post handling of this site, now its targetted to the same page but could be send to other page
    if ($_SERVER['REQUEST_METHOD'] == 'POST')
    {
    
        $sl_store = $_POST['title'];
        $sl_zip = $_POST['zipcode'];
    
        $id = $_POST['storelocator_id'];
        $wpdb->query( $wpdb->prepare("UPDATE w_store_locator SET sl_store='$sl_store',sl_zip='$sl_zip' WHERE sl_id='$id'")) or
            die(mysql_error());
    
        echo 'De gegevens zijn succesvol opgeslagen in de database, <a href="../editstore">je kan nu hier terug</a>';
    
    } else
    {
    ?>
    <h1>Wijzig Praktijk</h1>
    <a HREF="history.back()">Terug naar uw praktijk(en) overzicht.</a>
    
    <?php
    $pagina = filter_input(INPUT_GET, 'praktijk_id_vm', FILTER_VALIDATE_INT);
    if($pagina === FALSE) {
        echo '<h2>This is not the right way!</h2>';
    }
    else {
    $praktijk_id = $_GET['praktijk_id_vm'];
    $user_id_vm = $current_user->ID ;
    $praktijken = $wpdb->get_results("SELECT * FROM w_store_locator WHERE sl_id = $praktijk_id AND user_id =$user_id_vm ");
    
    echo 'debug info: practise id praktijk id: ';
    echo $praktijk_id;
    echo ' debug infor: user_id (users) de user_id_vm: ';
    echo $user_id_vm;
    
    if ($user_id_vm != $praktijken[0]->user_id) { // user_id niet gelijk dan geen pagina weergeven (vanwege evt directe browser benadering van deze pagina)
        echo "<h2>Dit is natuurlijk niet de bedoeling</h2>"    ;
            }
    else {
    
    echo '';
    
    echo "<table>";
    echo "<tr>";
    echo "<td>".'Praktijknaam'."</td>";
    echo "<td>".'Adres'."</td>";
    echo "<td>".'Type praktijk'."</td>";
    echo "</tr>";
    foreach($praktijken as $praktijk){
    
    echo "<tr>";
    echo "<td>".$praktijk->sl_store."</td>";
    echo "<td>".$praktijk->sl_address."</td>";
    echo "<td>".$praktijk->sl_tags."</td>";
    echo "</div></tr>";
    }
    echo "</table>";
    }}
    ?>
    
    <h1> Wijzig praktijkgegevens van <?=$praktijken[0]->sl_store; ?></h1>
    
    <form action="" method="post" enctype="multipart/form-data">
    <input type="hidden" name="storelocator_id" id="storelocator_id" value="<?=$praktijken[0]->sl_id; ?>" />
    
        	<fieldset>
            	<legend>Praktijkgegevens</legend>
    
                <div>
                	<label for="title">Praktijknaam</label>
                    <input type="text" name="title" id="title" value="<?=$praktijken[0]->sl_store;?>" placeholder="b.v. Tandartspraktijk het Contactpunt" required="required" class="box_shadow" maxlength="255" />
                </div>
                <div>
                	<label for="description">Praktijk omschrijving</label>
                	<textarea id="description" name="description" class="box_shadow" style="min-height: 50px;" rows="10" cols="60" placeholder="Onze praktijk heeft 6 medewerkers en wij zijn gespecialiseerd in de esthetische tandheelkunde."><?=(isset($praktijken[0]->sl_description)) ? $praktijken[0]->sl_description : '';?></textarea>
                </div>
                <div>
                	<label for="price_description">Geef uw "Tag" op, hiermee omschrijft u in 1 woord waar uw praktijk op is gericht</label>
       	         <select size="1">
                 <option  value="<?=$praktijken[0]->sl_tags;?>" placeholder="tandarts" class="box_shadow" maxlength="255" /></option>
    	<option  value="tandarts">Algemene Tandheelkunde</option>
    	<option value="mondhygienist">mondhygienist</option>
     </select>  </div>
    
                <div>
                	<label for="email">Praktijk e-mail</label>
                    <input type="email" name="email" id="email" value="<?=$praktijken[0]->sl_email;?>" placeholder="praktijk@info.nl" class="box_shadow" maxlength="255" />
                </div>
                <div>
                	<label for="phone">Telefoonnummer praktijk</label>
                    <input type="text" name="phone" id="phone" value="<?=$praktijken[0]->sl_phone;?>" placeholder="012-3456789" class="box_shadow" />
                </div>
                <div>
                	<label for="website">Website</label>
                    <input type="url" name="website" id="website" value="<?=$praktijken[0]->sl_website;?>" placeholder="http://www.tandartshetcontact.nl" class="box_shadow" maxlength="255" />
                </div>
                <div>
                	<label for="address">Adres</label>
                    <input type="text" name="address" id="address" value="<?=$praktijken[0]->sl_address;?>" placeholder="Contactweg 12" required="required" class="box_shadow" maxlength="255" />
                </div>
                <div>
                	<label for="zipcode">Postcode</label>
                    <input type="text" name="zipcode" id="zipcode" value="<?=$praktijken[0]->sl_zip;?>" placeholder="1234AB" required="required" class="box_shadow" maxlength="6" />
                </div>
                <div>
                	<label for="city">Plaats</label>
                    <input type="text" name="city" id="city" value="$praktijken[0]->sl_city;?>" placeholder="Amsterdam" required="required" class="box_shadow" maxlength="255" />
                </div>
                <div>
                <input type="submit" value="Bewaar deze gegevens" />
                </div>
            </fieldset>
        </form>
    </div>
    </div>
    
    <? }?>
    <?php get_footer(); ?>
  3. Charleston Software Associates
    Member
    Plugin Author

    Posted 1 year ago #

    All support for SLP is moving to the CSA website. Posts on that site now take precedence and get my attention first. Visit the new support forum here:
    http://www.charlestonsw.com/forums/forum/support-2/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.