on3advertising (@on3advertising)

Forum Replies Created

Viewing 21 replies - 1 through 21 (of 21 total)

  • on3advertising
    Participant

    @on3advertising

    Thanks for the response, but can any one with pre-existing knowledge expound a bit more on how to do that? Once I see just a small example I can go from there.


    on3advertising
    Participant

    @on3advertising

    404 error on that plugin


    on3advertising
    Participant

    @on3advertising

    Also, this only happens when I enter the site from an external source. So I have a hyperlink website.com/forum/?cid=1234

    If I just copy/paste that URL and enter the site directly it works fine.


    on3advertising
    Participant

    @on3advertising

    Actually I still get a SQL error when entering letters instead of #’s into the field. Also I need to make sure there is a valid result before submitting


    on3advertising
    Participant

    @on3advertising

    Just got the whole thing working. Here is the code:

    function restrictForum(){
    $db_name = 'dbname';
    $con = mysql_connect("url","username","password");
    mysql_select_db("$db_name")or die("cannot select DB");
    $cust_id = mysql_real_escape_string($_GET['cid']);
    $sql = "SELECT * FROM customer_data WHERE customer_number = $cust_id";
    $result= mysql_query($sql);
    $cust_id_form = ('
    Enter Your Customer #
    ');
    if ( isset( $_GET['cid'] ) && !empty( $_GET['cid'] ) && mysql_num_rows($result) == 1) {
    // cid (customer ID) is present, show the bbPress login form
    echo ('Please enter your username and password to continue.');
    echo do_shortcode('[bbp-login]');

    } elseif ( $_GET['error'] == true ) {

    // cid entered was not valid
    echo 'The customer ID you entered is not valid.';

    } elseif (!is_user_logged_in()){
    echo $cust_id_form;
    }
    }
    add_shortcode('forum-login-restrict','restrictForum');


    on3advertising
    Participant

    @on3advertising

    Okay something really strange is happening, I think it’s something to do with the GET method. When I enter the customer ID into the field and hit Submit, my URL blows up! For some reason it’s displaying my connection information for the WordPress db (obviously a big problem). And it keeps growing every time I submit. Not sure if it’s because I’m on a xampp server. Looks something like this


    http://localhost/~homeFolder/Website/forum/?cid=555112&log=myusername&pwd=THEPASSWORD&user-cookie=1&redirect_to=http%3B%2C%Mlocalhost%2F~homeFolder%Website%2F&_wpnonce=a7841878&_wp_http_referer=%2F~homeFolder%Website%2Fforum%2F


    on3advertising
    Participant

    @on3advertising

    I’m so close using Jeff’s solution!

    I added a checker to the customer ID in the initial if statement since it was passing through regardless of what I entered.
    && mysql_num_rows($result) == 1

    So the complete code ended up looking like this:
    function restrictForum(){
    $db_name = 'dbname';
    $con = mysql_connect("url","usr","password");
    mysql_select_db("$db_name")or die("cannot select DB");
    $cust_id = mysql_real_escape_string($_GET['cid']);
    $sql = "SELECT * FROM customer_data WHERE customer_number = $cust_id";
    $result= mysql_query($sql);
    if ( isset( $_GET['cid'] ) && !empty( $_GET['cid'] ) && mysql_num_rows($result) == 1) {
    // cid (customer ID) is present, show the bbPress login form
    echo 'Please enter your username and password to complete the login process ';
    echo do_shortcode('bbp-login');

    } elseif ( $_GET['error'] == true ) {

    // cid entered was not valid
    echo 'The customer ID you entered is not valid.';

    } else {
    echo ('
    Enter Your Customer #
    (form name="cust-form" id="cust-form" method="get")
    (input name="cid" id="cid" type="text" maxlength="6" /)
    (input type="submit" value="Validate"'/)
    (/form));
    // cid is absent so show the form to validate it
    // do your custom form here that asks for the customer ID. Then if the customer ID
    // is correct/valid reload this page like /login?cid=123456 which will show
    // the bbPress login form.
    }
    }
    add_shortcode('forum-login-restrict','restrictForum');

    It’s weird though, whenever I enter an invalid customer ID, I get the MySQL error saying “mysql_num_rows() expects parameter 1 to be resource, boolean”.

    It’s also annoying that the bbpress shortcode I’m embedding is now showing up as text, literally “bbp-login” rather than the actual form using:
    echo do_shortcode('bbp-login');


    on3advertising
    Participant

    @on3advertising

    I like your method, I’m also trying to figure out a way to keep it on one page. I just noticed your post so I will have to try it, but I did something like this. It doesn’t work:

    I have a login-form.php with the basic stuff (this forum keeps stripping my form code so I have to put some sloppy stuff in here:

    form method = "get"
    input name="cid" id="cid" type="text"

    I have a checklogin.php file:

    if(isset($_POST['submit'])){
    $db_name = 'dname';
    $con = mysql_connect("url,"username","password");
    mysql_select_db("$db_name")or die("cannot select DB");
    $cust_id = $_GET['cid'];
    $cust_id = stripslashes($cust_id);
    $cust_id = mysql_real_escape_string($cust_id);
    $sql="SELECT * FROM customer_data WHERE customer_number='$cust_id', LIMIT 1";
    if(mysql_num_rows($sql) == 1){
    $row = mysql_fetch_array($sql);
    session_start();
    $_SESSION['cid'] = $row['cid'];
    echo('kind of worked');
    } else {
    echo("worked");
    }
    }else {
    include_once("login-form.php");
    }

    Then I made my shortcode in functions.php that just calls the checklogin.php file:

    function restrictForum(){
    include_once("checklogin.php");
    }
    add_shortcode('forum-login-restrict','restrictForum');

    There is something seriously wrong with this method. I am studying your solution as best as I can to try and implement that as well.


    on3advertising
    Participant

    @on3advertising

    I like your method, I’m also trying to figure out a way to keep it on one page. I just noticed your post so I will have to try it, but I did something like this. It doesn’t work:

    I have a login-form.php with the basic stuff (this forum keeps stripping my form code so I have to put some sloppy stuff in here:

    form method = "get"
    input name="cid" id="cid" type="text"

    I have a checklogin.php file:

    if(isset($_POST['submit'])){
    $db_name = 'synoptix';
    $con = mysql_connect("url,"username","password");
    mysql_select_db("$db_name")or die("cannot select DB");
    $cust_id = $_GET['cid'];
    $cust_id = stripslashes($cust_id);
    $cust_id = mysql_real_escape_string($cust_id);
    $sql="SELECT * FROM customer_data WHERE customer_number='$cust_id', LIMIT 1";
    if(mysql_num_rows($sql) == 1){
    $row = mysql_fetch_array($sql);
    session_start();
    $_SESSION['cid'] = $row['cid'];
    echo('kind of worked');
    } else {
    echo("worked");
    }
    }else {
    include_once("login-form.php");
    }

    Then I made my shortcode in functions.php that just calls the checklogin.php file:

    function restrictForum(){
    include_once("checklogin.php");
    }
    add_shortcode('forum-login-restrict','restrictForum');

    There is something seriously wrong with this method. I am studying your solution as best as I can to try and implement that as well.


    on3advertising
    Participant

    @on3advertising

    sd


    on3advertising
    Participant

    @on3advertising

    Jared, thanks for the feedback. The more I thought about it, about a thousand different ways to do it popped into my head as well (spun my brain into a scrambled egg). At this point, I’ve basically started to write the custom login from the ground up. I’m going to create a shortcode out of it at the end.

    I just started it but so far I just have the basic connection and query going:

    function restrictForum(){
    $db_name = 'dbname';
    $con = mysql_connect("URL","username","password*");
    mysql_select_db("$db_name")or die("cannot select DB");
    $cust_no = $_POST['custno'];
    $sql = "SELECT * FROM customer_data WHERE customer_number = $cust_no";
    echo('Customer #');
    }

    I previously had this small bit into a shortcode that just checked if the user was logged in then provided the bbpress login form if they weren’t:
    function restrictForum(){

    if(!is_user_logged_in()){
    echo('You must login to access the forum');
    echo do_shortcode('[bbp-login]');
    }
    }

    add_shortcode('forum-login-restrict','restrictForum');


    on3advertising
    Participant

    @on3advertising

    This is getting more complicated the more I realize what I need to do. Basically I have to add an extra login field to the WordPress / BBPress login. But the data in the field I have to add to the form resides on a separate database. So the complicated part is that I have ‘Username’ and ‘Password’ that is authenticated on the WordPress database and “Customer Number” that resides on another database. I’m not sure if there is a way to authenticate one login using multiple db’s.

    In reply to: Mark topic as closed

    on3advertising
    Participant

    @on3advertising

    Never mind I just noticed you modified your post 🙂

    In reply to: Mark topic as closed

    on3advertising
    Participant

    @on3advertising

    Zaerl, you rock. Thank you for that. Except I think you actually did include the double ampersand in your original source.


    on3advertising
    Participant

    @on3advertising

    I’m assuming this problem is blatantly avoided by bbPress. A response with a Yes we will do it or No we won’t/can’t would at least be nice so I can move on to paying someone for a fix.


    on3advertising
    Participant

    @on3advertising

    Where is this plugin located? I clicked on your first link and it takes me to a WordPress login page.


    on3advertising
    Participant

    @on3advertising

    I should mention that having to go to a forum, then a topic, then a post, then clicking on the username from there is not intuitive and a poor workaround to getting to the bbPress profile.


    on3advertising
    Participant

    @on3advertising

    netweb, that was the other widget I tried. I created a support topic on that one as well. Both widgets behave identically., which lead me to believe it could be a bbPress specific issue.

    jared, thanks for the ticket reference. I hope they come out with something soon. Right now, I can’t figure out a workaround.


    on3advertising
    Participant

    @on3advertising

    I am using Search bbPress https://wordpress.org/extend/plugins/search-bbpress/. Initially, I didn’t post it on there because there is a total of 5 topics their entire shelf life with one resolution (resolved by the same user who created it). But I did just submit it there because I’m not entirely sure if it’s bbPress’s engine or the plugin.

    I guess I’m trying to figure out if it’s a matter of how it’s finding the results, how it’s displaying the results, or how bbPress stores them. I assume it’s probably not bbPress itself at this point.


    on3advertising
    Participant

    @on3advertising

    I fixed it. The problem was the theme. Either I was installing it incorrectly and not properly activating it as a WordPress Child Theme, or the theme was simply broken. I installed a standalone bbpress theme here and it worked right off the get go. Topic can be closed.


    on3advertising
    Participant

    @on3advertising

    Unfortunately I never got this sorted out because no one responded within the time of my deadline. So I deleted the entire standalone installation off my server and installed a fresh instance of WordPress. Then I installed/activated bbPress within the Admin panel of WordPress. At this point, I uploaded the bb-blueSands theme to my themes directory in WordPress. Nothing changed, it still looks exactly like “TwentyTen”. When I try to activate the new theme, it errors, “The following themes are installed but incomplete. Themes must have a stylesheet and a template…template is missing.” I don’t understand how to properly activate a bbPress Theme so i can actually use this as a real forum module.

Viewing 21 replies - 1 through 21 (of 21 total)